On Sep 22, 2007, at 4:38 PM, Andre Garzia wrote:

Aloha my friends,
Now I bring to you folks an external ...

Congratulations Andre!

External mania is catching! but readers who've never made an external may want to skip the rest of this post.

Before you go off the deep end, Andre, here's a description of a problem I encountered last spring ( I reported it to Mark Waddingham but I don't know if he fixed it.) and how to get around it. If you ever get the compiler error I mention (especially if you try to add objective-c code to your external), keep this fix in mind.

----

I had an xCode project made with External Creator V1.rev; let's call it "xxx6" (it was the sixth "xxx" project I'd made). Because it was nearly finished, I decided to rename the project "xxx". I first renamed the "xxx6.c" file, and as is my practice, rebuilt the project after I made the change. Even though renaming the file was was the *only* change I made, the build failed!

The error was with a "361: error: parse error before string constant" at the macro EXTERNAL_BEGIN_DECLARATIONS("xxx").

I preprocessed the file and looked at the macro expansion—everything was fine! I fiddled with every applicable project setting to no avail. I even posted to the xCode-Users mailList... but in the interest of simplicity I left out the critical bit of info when I described the problem: the macro contained another macro invocation, EXTERNAL_REFERENCE_LIBRARY, which was being expanded to include a fateful and erroneous:

extern "C"

but why? This was a C file, not C++ (which alone uses extern "C" declarations)! I looked at external.h and I saw that EXTERNAL_REFERENCE_LIBRARY, that contains the "extern" declaration, was being expanded if _MACOS was true, without any #ifdef for __cplusplus. When I changed:

#ifdef _MACOS

to:

#if defined(_MACOSX) && defined(__cplusplus)

in External.h, the build ran to successful completion. The question then became, "How was I able *ever* to get successful C builds?" The answer is that External Creator V1.rev creates a source file whose filetype for xCode is "sourcecode.cpp.cpp" even though the filename is "xxx.c".

When I renamed my source file, xCode reset its "filetype" to "sourcecode.c.c", thereby triggering the error on extern "C", which is recognized only in C++.

So there are two things to fix: the conditional in external.h, and the script for building an xCode C project in External Creator V1.rev.

I am so glad I solved the puzzle at last—I would surely have recognized the problem sooner if I hadn't been off the C/C++ wagon for the last 3 years...


tereza


_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to