【问题标题】:XCode 4.2.1 - Problems with va_list, va_start, va_end from SFML 2.0XCode 4.2.1 - 来自 SFML 2.0 的 va_list、va_start、va_end 问题
【发布时间】:2012-02-16 21:02:16
【问题描述】:

这里有几个问题。首先,包含 cstdarg 会抛出这个错误:

/usr/include/c++/4.2.1/cstdarg:59:11:{60:9-60:11}: error: no member named 'va_list' in the global namespace [3]
   using ::va_list;

然后,包括 c++locale.h 会抛出这个:

/usr/include/c++/4.2.1/bits/c++locale.h:76:5: error: use of undeclared identifier 'va_start' [3]
     va_start(__args, __fmt);
     ^
/usr/include/c++/4.2.1/bits/c++locale.h:84:5: error: use of undeclared identifier 'va_end' [3]
     va_end(__args);
     ^
/usr/include/c++/4.2.1/cstdarg:54:20: note: instantiated from:
 #define va_end(ap) va_end (ap)

我不知道该怎么办。我正在使用 SFML 2.0,其中包含 Graphics.hpp 会给出这些错误。任何想法如何解决这个问题?

【问题讨论】:

    标签: xcode4 variadic-functions


    【解决方案1】:

    我遇到了同样的问题。我发现在我的标题搜索路径中同时包含/usr/local/include/**/usr/include/** 破坏了所有标准模板库。我使用的其中一个库在/usr/lib/usr/include 中安装了它自己,我发现卸载这个库并将其重新安装到/usr/local/lib/usr/local/include 解决了这个问题。

    我尝试按照上面的建议包含stdio.h,但没有帮助。

    我使用的系统是 Mac OS 10.8 和 XCode 4.3

    【讨论】:

      【解决方案2】:

      我在一个项目中遇到了这个问题,并通过在开始时添加一个额外的包含来解决它,该包含负责加载丢失的元素:

      #include <stdio.h>
      

      如果您查看该文件,您会看到定义:

      #ifndef _VA_LIST
      #define _VA_LIST
      /* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
       * __gnuc_va_list and include <stdarg.h> */
      typedef __darwin_va_list    va_list;
      #endif
      

      【讨论】:

        【解决方案3】:

        普通 C 头文件与 C++ 头文件不兼容。尝试包含cstdarg 而不是stdarg.h

        【讨论】:

        • 谢谢,这会产生同样的错误。如果包含 stdarg.h,看起来 XCode 会自动调用 cstdarg
        • 没办法。首先,不是 Xcode 在做这件事,而是 C 预处理器。其次,它将因此包括您要求的任何内容。
        • 我明白了,这很有趣
        猜你喜欢
        • 2012-08-21
        • 1970-01-01
        • 2012-03-05
        • 2016-02-10
        • 2016-04-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多