Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 23, 2008, 04:13 PM   #1
qwerty2k
macrumors regular
 
Join Date: Dec 2007
c++ in xcode compile errors

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.
qwerty2k is offline   0 Reply With Quote
Old Feb 23, 2008, 04:16 PM   #2
parapup
macrumors 65816
 
parapup's Avatar
 
Join Date: Oct 2006
Quote:
Originally Posted by qwerty2k View Post
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.
parapup is offline   0 Reply With Quote
Old Feb 23, 2008, 04:26 PM   #3
qwerty2k
Thread Starter
macrumors regular
 
Join Date: Dec 2007
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)
qwerty2k is offline   0 Reply With Quote
Old Feb 23, 2008, 09:35 PM   #4
parapup
macrumors 65816
 
parapup's Avatar
 
Join Date: Oct 2006
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?
parapup is offline   0 Reply With Quote
Old Feb 24, 2008, 05:44 AM   #5
qwerty2k
Thread Starter
macrumors regular
 
Join Date: Dec 2007
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?
qwerty2k is offline   0 Reply With Quote
Old Feb 24, 2008, 08:44 AM   #6
parapup
macrumors 65816
 
parapup's Avatar
 
Join Date: Oct 2006
Quote:
Originally Posted by qwerty2k View Post
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.
parapup is offline   0 Reply With Quote
Old Feb 24, 2008, 09:00 AM   #7
qwerty2k
Thread Starter
macrumors regular
 
Join Date: Dec 2007
thank you for your suggestions, however the error still occurs
qwerty2k is offline   0 Reply With Quote
Old Feb 24, 2008, 09:18 AM   #8
parapup
macrumors 65816
 
parapup's Avatar
 
Join Date: Oct 2006
Quote:
Originally Posted by qwerty2k View Post
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?
parapup is offline   0 Reply With Quote
Old Jun 27, 2008, 01:51 AM   #9
Nerdcoder
macrumors newbie
 
Join Date: Sep 2006
Found a solution

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...
Nerdcoder is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Moving from xcode 3.2 to xcode 4.5.2 compilation error for 'abs' macro in stdlib.h hrishidev Mac Programming 7 Jun 2, 2013 10:36 AM
Please compile this kext. rabidz7 Mac Programming 7 Apr 18, 2013 07:13 PM
How to compile a pre-made xcode project into a library dancks Mac Programming 1 Oct 4, 2012 02:38 PM
XCode 4.4.1 to Xcode 4.5 in Mountain Lion VinegarTasters OS X 10.8 Mountain Lion 2 Sep 19, 2012 08:55 PM
Xcode 4.5 errors Sixtafoua iPhone/iPad Programming 1 Jun 13, 2012 07:04 PM

Forum Jump

All times are GMT -5. The time now is 10:14 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC