Mac OS Clang 配置问题

2015-01-30 00:32:35 +08:00
 mianju

我是在Sublime Text 2 里面装SublimeClang的,结果出现这个问题:
/usr/include/c++/4.2.1/bits/c++locale.h:77,5 - Error - use of undeclared identifier 'va_start'
/usr/include/c++/4.2.1/bits/c++locale.h:85,5 - Error - use of undeclared identifier 'va_end'

以下是va_start/end在的地方

#ifndef _C_LOCALE_H
#define _C_LOCALE_H 1

#pragma GCC system_header

#include <clocale>
#include <cstring>   // get std::strlen
#include <cstdio>    // get std::vsnprintf or std::vsprintf
#include <cstdarg>

#define _GLIBCXX_NUM_CATEGORIES 0

_GLIBCXX_BEGIN_NAMESPACE(std)

  typedef int*          __c_locale;

  // Convert numeric value of type double and long double to string and
  // return length of string.  If vsnprintf is available use it, otherwise
  // fall back to the unsafe vsprintf which, in general, can be dangerous
  // and should be avoided.
  inline int
  __convert_from_v(const __c_locale&, char* __out, 
           const int __size __attribute__((__unused__)),
           const char* __fmt, ...)
  {
    char* __old = std::setlocale(LC_NUMERIC, NULL);
    char* __sav = NULL;
    if (std::strcmp(__old, "C"))
      {
    __sav = new char[std::strlen(__old) + 1];
    std::strcpy(__sav, __old);
    std::setlocale(LC_NUMERIC, "C");
      }

    va_list __args;
    va_start(__args, __fmt);

#ifdef _GLIBCXX_USE_C99
    const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
#else
    const int __ret = std::vsprintf(__out, __fmt, __args);
#endif

    va_end(__args);

    if (__sav)
      {
    std::setlocale(LC_NUMERIC, __sav);
    delete [] __sav;
      }
    return __ret;
  }

_GLIBCXX_END_NAMESPACE

#endif

另外,V友能推荐个ST 2 的代码补全插件,最好想IDE一样,直接编写变提示的,自带的功能不够强大, 最后再推荐些其他好用的插件,谢谢~~

4717 次点击
所在节点    问与答
2 条回复
canautumn
2015-01-30 01:03:17 +08:00
试试命令行下能不能编译。如果可以,多半是环境变量错了。sublime调用的shell和平时用的shell的配置可能不一样。
另外为啥不用xcode?用st写c++太蛋疼了吧
Valyrian
2015-01-30 03:28:37 +08:00
SublimeLinter

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/166648

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX