Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode with boost "Semantic Issue - undeclared identifier va_start"

C++locale.h
->Semantic Issue
-->Use of undeclared identifier 'va_start'
->Semantic Issue
-->Use of undeclared identifier 'va_end'

First time using boost, downloaded it using ports and created a command line project in XCode. Header Search Path: /usr/include/**

There is nothing in the code yet, just the main function that comes with the default proj.

Just don't know what to do, never expected this to happen.

EDIT1:

First occurrence:

#ifndef _GLIBCXX_CSTDARG
#define _GLIBCXX_CSTDARG 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <stdarg.h>

// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef va_end
#define va_end(ap) va_end (ap)
#endif

_GLIBCXX_BEGIN_NAMESPACE(std)

  using ::va_list;

_GLIBCXX_END_NAMESPACE

#endif

It's a file without extension in \usr\include\c++\4.2.1 and i just realized that this file has nothing to do with boost, there is something nasty happening here.

EDIT2: After fixing the include dir to /opt/local/include/** new errors appeared:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/type_traits:214:46:
Use of undeclared identifier 'nullptr_t'; did you mean 'nullptr'?

There are other errors, all related to these files in the folder sr/lib/c++/v1/ why is that? These file seems to be some core functionality, they can't be broke.

Here is a pic of the errors, maybe ou guys see something Errors

EDIT3: Changing the compiler from Apple LLVM to GCC LLVM reduces the errors to only one: "vspintf is not a member of 'std'" in c++locale.h. Ok, now I'm completely lost.

like image 998
Paulo Henrique Avatar asked Sep 24 '12 21:09

Paulo Henrique


4 Answers

I had the same issue, I've installed Boost with homebrew and when I add the 'Header Search Path' (/usr/local/Cellar/boost/1.54.0/include with the recursive option) in XCode the build throw those errors.

To fix it I changed the recursive option to non-recursive on the 'Header Search Path' and it worked.

like image 82
icapurro Avatar answered Nov 18 '22 15:11

icapurro


From the latest comment, I think I know the problem.

Header Search Path: /usr/include/**

Just created another fresh XCode command line tool app. There is no errors at all when building the Hello World, but just adding the Header Search Path breaks the compilation with the above stated error, there is no reference to boost in my code yet, just added the search path.

Where did you get the search path /usr/include/**?

MacPorts installs everything to /opt/local, not /usr, so you want /opt/local/include (or /opt/local/include/** or /opt/local/include/boost); adding /usr/include/** isn't going to help at all with Boost.

However, it may break your code even before you get to Boost.

What's in /usr/include is Xcode's Command Line Tools. If you don't have these, you've got an incomplete and unusable set of headers; if you do, you've got a set of headers that conflicts with SDK-based builds.

The answer is to not add /usr/include/** to your search path.

Or, if you really need to add it (but really, you don't), change the Base SDK to "Current OS X" instead of "Latest OS X", which means you'll be getting your default headers out of /usr/include instead of, e.g., /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include, and of course adding a path that's already there won't lead to any conflicts.

like image 43
abarnert Avatar answered Nov 18 '22 16:11

abarnert


I had this problem and solved it. In XCode on osx mavericks had to add /opt/local/libs/ to the library search path (non-recursive). I then added /opt/local/include/ to the header search path (also non-recursive).

like image 36
Nathan Avatar answered Nov 18 '22 16:11

Nathan


You need to #include <stdarg.h> in order to use the va_start macros et al. If those errors are happening in a header file, then that header file should include <stdarg.h>; if it doesn't, you can work around it by including it yourself before you include the problematic header (but you should also report the issue to the library developers, if possible).

like image 2
Adam Rosenfield Avatar answered Nov 18 '22 14:11

Adam Rosenfield