首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编译现有代码库时出现编译错误

编译现有代码库时出现编译错误
EN

Stack Overflow用户
提问于 2010-06-12 20:44:45
回答 1查看 565关注 0票数 0

在Mac OS上使用原生构建设置构建现有代码时,我在编译阶段遇到了一些基本的奇怪错误。

你们有没有什么想法,因为我已经看到,它也在这个论坛之前讨论过,没有任何好的理由。我看不到包含任何冲突的文件。但是我仍然无法编译代码,因为出现了这个错误。

源代码类似于下面给出的代码,并出现编译错误

代码语言:javascript
复制
$ 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;
         }
     }

用于编译的标志

代码语言:javascript
复制
 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-06-12 21:41:19

看起来您正在尝试使用OSX10.3开发人员工具(Xcode等人),并试图以OSX10.4为目标,这显然是行不通的。或者更改您的构建命令以删除不兼容的标志,例如-mmacosx-version-min=10.4,或者升级到更新版本的OS X+ Xcode +SDK。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3028691

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档