tags:

views:

108

answers:

1

Hi,

While building an existing code base on Mac OS using its native build setup I am getting some basic strange error while compilation phase.

Does any of you have any idea, as I have seen it's been discussed earlier as well in this forum without any good reason. I can not see any conflicting files being included. But still I am unable to compile the code because this error appears.

Source are like the code given below and compilation error appears

 $ cat a.h
#include <string>
#include <sstream>

namespace brijesh
 {

typedef std::string String;

 template<class T>
 String
          toString(T value) {
     std::ostringstream buffer;
    buffer << value;
 return buffer.str();
 }

$ cat b.h
      #include "a.h"
  namespace brijesh
  {

    class Platform
    {
    public:
     static String getName();
   };


   }

  $ cat b.cpp
   #include "b.h"

   namespace brijesh {

    String
     Platform::getName()
     {
       String  name = "UNKNOWN";
       #ifdef  LINUX
        name = "linux";
       #endif
       #ifdef  MACOSX
         name = "Mac";
       #endif
         return name;
        }
      }

flags used for compilation

 g++ -c -o test.o -DRELEASE_VERSION -ggdb -arch ppc -mmacosx-version-min=10.4 -pipe -fpermiss    ive -nostdinc -nostdinc++ -isystem /Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3    .3 -I/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++ -I/Developer/SDKs/MacOS    X10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin -isystem /Developer/SDKs/MacOSX10.3.9.    sdk/usr/include -F/Developer/SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks -Wreturn-type -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -Wall -Wno-multichar -Wno-unk    nown-pragmas  -Wno-long-double -fconstant-cfstrings  -MP -MMD x.cpp



/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/bits/locale_facets.h: In constructor 'std::collate_byname<_CharT>::collate_byname(const char*, size_t)':
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/bits/locale_facets.h:1072: error: '_M_c_locale_collate' was not declared in this scope
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin/bits/messages_members.h: In constructor 'std::messages_byname<_CharT>::messages_byname(const char*, size_t)':
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin/bits/messages_members.h:79: error: '_M_c_locale_messages' was not declared in this scope
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits: At global scope:
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: 'float __builtin_huge_valf()' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: 'float __builtin_huge_valf()' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:897: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: 'float __builtin_nanf(const char*)' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: 'float __builtin_nanf(const char*)' cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:899: error: a function call cannot appear in a constant-expression
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:900: error: field initializer is not constant
/Developer/SDKs/MacOSX10.3.9.sdk/usr/include/gcc/darwin/3.3/c++/limits:915: error: field initializer is not constant

the code of the

A: 

It looks like you're trying to use OS X 10.3 developer tools (Xcode et al) and are trying to target OS X 10.4, which is obviously not going to work. Either change your build command to remove incompatible flags, such as -mmacosx-version-min=10.4, or upgrade to a more current version of OS X + Xcode + SDKs.

Paul R
Thanks Paul, however I wanted to build it on 10.5 SDK machine with powerpc options. is there any place where I can get appropriate flags for building it with ppc build and SDK 10.5?
brijesh
@brijesh: what version of Xcode do you have ? I suggest using Xcode 2.4 or preferably 2.5 on OS X 10.5. You will need to select OS X 10.4u SDK.
Paul R
Hi Paul, I am not sure how to check the XCode Version? I can see the SDK installed is 10.5. Please let me know if you have any suggestion.
brijesh
@brijecsh: In `Xcode`, look at the first menu item in the first menu: `About Xcode`. Alternatively in the `Finder` select `Xcode` and do a `Get Info`.
Paul R