V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
mianju
V2EX  ›  问与答

Mac OS Clang 配置问题

  •  
  •   mianju · 2015-01-30 00:32:35 +08:00 · 4710 次点击
    这是一个创建于 3410 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我是在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一样,直接编写变提示的,自带的功能不够强大, 最后再推荐些其他好用的插件,谢谢~~

    2 条回复    2015-01-30 03:28:37 +08:00
    canautumn
        1
    canautumn  
       2015-01-30 01:03:17 +08:00 via iPhone
    试试命令行下能不能编译。如果可以,多半是环境变量错了。sublime调用的shell和平时用的shell的配置可能不一样。
    另外为啥不用xcode?用st写c++太蛋疼了吧
    Valyrian
        2
    Valyrian  
       2015-01-30 03:28:37 +08:00
    SublimeLinter
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2465 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 385ms · UTC 12:36 · PVG 20:36 · LAX 05:36 · JFK 08:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.