PDA

View Full Version : c++ in xcode compile errors




qwerty2k
Feb 23, 2008, 04:13 PM
Hi, i was previously coding a project in Linux using CodeBlocks, it is using boost, guichan gui library and sdl as a backend. Ive imported my project into XCode and put all the required libraries etc into the project.

However im getting some compile errors.

the errors are in the complex numbers standard c++ header:

error: 'snprintf' is not a member of 'std'
error: '__pow_helper' is not a member of 'std'

Now these are standard c++ headers, i haven't altered any of them so i am at a loss as to why they won't compile.



parapup
Feb 23, 2008, 04:16 PM
error: 'snprintf' is not a member of 'std'
error: '__pow_helper' is not a member of 'std'


Looks like it's namespace resolution related - your default namespace seems to be set to std (using namespace std) and the C functions are part of global namespace specified explicity by prefixing :: to the function.

So try using ::snprintf and the like and see if that resolves the errors.

qwerty2k
Feb 23, 2008, 04:26 PM
how can i open the file as an admin because its in an area a normal user can't edit (also in the file there are lots of references to functions prefixed with std:: and it doesn't error out on any of them)

parapup
Feb 23, 2008, 09:35 PM
Ok, I missed the part about the error being in standard headers.

Can you #include <cstring> *before* #including the standard header which gives you the snprintf error and see?

qwerty2k
Feb 24, 2008, 05:44 AM
didn't work, gave me even more errors, the fsprintf errors are now in c++locale.h in the following bit of code:

#ifdef _GLIBCXX_USE_C99
const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
#else
const int __ret = std::sprintf(__out, __fmt, __prec, __v);
#endif


i was thinking maybe its to do with gcc4? since iirc on ubuntu when i was coding i was compiling with gcc3?

parapup
Feb 24, 2008, 08:44 AM
i was thinking maybe its to do with gcc4? since iirc on ubuntu when i was coding i was compiling with gcc3?

Yeah - sounds like some weird gcc/libstdc++ bug. But before I give up I have one last thing for you to try - #include <cstdio> and #include <cstdarg> in the files where you use snprintf - that _should_ get rid of the snprintf error I think.

qwerty2k
Feb 24, 2008, 09:00 AM
thank you for your suggestions, however the error still occurs :(

parapup
Feb 24, 2008, 09:18 AM
thank you for your suggestions, however the error still occurs :(

Hmm I am intrigued - do you have a reduced test case - like may be just copy the failing part of the code and create a standalone header and .cpp to reproduce this? If so post the .h/.cpp here and I will try to see what's going on.

What version of gcc (gcc -v) are you compiling this under?

Nerdcoder
Jun 27, 2008, 01:51 AM
Hi digging around for a solution, I found a comment suggesting that using the recursive checkbox i include paths was the problem.

It was!.. Strange...