mianju
V2EX  ›  问与答

Mac OS Clang 配置问题

  •  
  •   mianju · Jan 30, 2015 · 5136 views
    This topic created in 4139 days ago, the information mentioned may be changed or developed.

    我是在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 replies    2015-01-30 03:28:37 +08:00
    canautumn
        1
    canautumn  
       Jan 30, 2015 via iPhone
    试试命令行下能不能编译。如果可以,多半是环境变量错了。sublime调用的shell和平时用的shell的配置可能不一样。
    另外为啥不用xcode?用st写c++太蛋疼了吧
    Valyrian
        2
    Valyrian  
       Jan 30, 2015
    SublimeLinter
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2877 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 08:14 · PVG 16:14 · LAX 01:14 · JFK 04:14
    ♥ Do have faith in what you're doing.