Jump to content
  • Advertisement
Sign in to follow this  
lincsimp

What's extern "C"?

This topic is 4839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey My prog has extern "C" in one of the libs. When I try to compile it I get: zlib/zlib.h:37: error: syntax error before string constant zlib/zlib.h:94: error: syntax error before "alloc_func" zlib/zlib.h:94: warning: no semicolon at end of struct or union zlib/zlib.h:101: error: syntax error before '}' token zlib/zlib.h:101: warning: data definition has no type or storage class zlib/zlib.h:103: error: syntax error before '*' token zlib/zlib.h:103: warning: data definition has no type or storage class zlib/zlib.h:217: error: syntax error before "strm" zlib/zlib.h:299: error: syntax error before "strm" zlib/zlib.h:334: error: syntax error before "strm" zlib/zlib.h:433: error: syntax error before "strm" zlib/zlib.h:507: error: syntax error before "strm" zlib/zlib.h:544: error: syntax error before "dest" zlib/zlib.h:562: error: syntax error before "strm" zlib/zlib.h:573: error: syntax error before "strm" zlib/zlib.h:594: error: syntax error before "strm" zlib/zlib.h:603: error: syntax error before "strm" zlib/zlib.h:662: error: syntax error before "strm" zlib/zlib.h:681: error: syntax error before "strm" zlib/zlib.h:696: error: syntax error before "dest" zlib/zlib.h:712: error: syntax error before "strm" zlib/zlib.h:747: error: syntax error before '*' token zlib/zlib.h:816: error: syntax error before '*' token zlib/zlib.h:1160: error: syntax error before "strm" zlib/zlib.h:1162: error: syntax error before "strm" zlib/zlib.h:1164: error: syntax error before "strm" zlib/zlib.h:1168: error: syntax error before "strm" zlib/zlib.h:1170: error: syntax error before '*' token zlib/zlib.h:1193: error: syntax error before "z" zlib/zlib.h:1197: error: syntax error before '}' token What am I doing wrong?? cheers

Share this post


Link to post
Share on other sites
Advertisement
This is very likely to be a problem with your own source code not the library. If you paste your code here we can help [smile].

ace

Share this post


Link to post
Share on other sites
Quote:
Original post by lincsimp
What's extern "C"?


It tells a C++ compiler to use C linking conventions, it does things like suppress name mangling etc.

What compiler are using and how are you using it.

[Edited by - snk_kid on August 15, 2005 8:02:24 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by lincsimp
Thanks! I'm using mingw.. Why would it be cauing an error though?

cheers


Well i know you can get the error message: error: syntax error before string constant when you have extern "C" statement in C code compiled under a C compiler but looking at zlib.h header that shouldn't happen (if i'm looking at the wright one) as it does the idiomatic:


#ifdef __cplusplus
extern "C" {
#endif
...

#ifdef __cplusplus
};
#endif


which checks to see if the macro __cplusplus is defined (predefined macro in standard C++) this allows you to determine if a compiler is compiling in C++ mode, if it is then the extern "C" statement is used if not then its not added.

So if your compiling this in C mode then __cplusplus should not be defined (and therefore not have an extern "C" statement).

[Edited by - snk_kid on August 15, 2005 9:35:10 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by lincsimp
zlib/zlib.h:37: error: syntax error before string constant


Sanity check: Check to make sure that any header you include before zlib.h doesn't have any syntax errors. The compiler may not be able to accurately locate the source of some sorts of errors, and so the error may "flow" into the next included file. Forgetting the semicolon at the end of a class declaration, for example.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!