V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
raincious
V2EX  ›  C

C++ REST SDK 2.1 引入的时候报“C2766 显式专用化”,求解决方案。

  •  
  •   raincious · 2014-08-10 19:52:07 +08:00 · 1185 次点击
    这是一个创建于 3557 天前的主题,其中的信息可能已经有所发展或是发生改变。
    这是错误:

    2> Http.cpp
    2> ...packages\cpprestsdk.2.1.0\build\native\include\cpprest/streams.h(459): error C2766: 显式专用化;已定义“Concurrency::streams::_type_parser_integral_traits<utf16char>”
    2> ...\packages\cpprestsdk.2.1.0\build\native\include\cpprest/streams.h(454) : 参见“_type_parser_integral_traits<unsigned short>”的前一个定义

    这是那段代码:

    判断如果是Windows,就定义两个宏
    .....
    #ifdef _MS_WINDOWS
    #define _INT_TRAIT(_t,_low,_high) template<> struct _type_parser_integral_traits<_t>{typedef std::true_type _is_integral;typedef std::false_type _is_unsigned;static const int64_t _min = _low;static const int64_t _max = _high;};
    #define _UINT_TRAIT(_t,_low,_high) template<> struct _type_parser_integral_traits<_t>{typedef std::true_type _is_integral;typedef std::true_type _is_unsigned;static const uint64_t _max = _high;};

    _INT_TRAIT(char,INT8_MIN,INT8_MAX)
    _INT_TRAIT(signed char,INT8_MIN,INT8_MAX)
    _INT_TRAIT(short,INT16_MIN,INT16_MAX)
    _INT_TRAIT(utf16char,INT16_MIN,INT16_MAX) // 这是 454 行
    _INT_TRAIT(int,INT32_MIN,INT32_MAX)
    _INT_TRAIT(long, LONG_MIN, LONG_MAX)
    _INT_TRAIT(long long, LLONG_MIN, LLONG_MAX)
    _UINT_TRAIT(unsigned char,UINT8_MIN,UINT8_MAX)
    _UINT_TRAIT(unsigned short,UINT16_MIN,UINT16_MAX) // 这是 459 行
    _UINT_TRAIT(unsigned int,UINT32_MIN,UINT32_MAX)
    _UINT_TRAIT(unsigned long, ULONG_MIN, ULONG_MAX)
    _UINT_TRAIT(unsigned long long, ULLONG_MIN, ULLONG_MAX)
    #else
    #define _INT_TRAIT(_t) template<> struct _type_parser_integral_traits<_t>{typedef std::true_type _is_integral;typedef std::false_type _is_unsigned;static const int64_t _min = std::numeric_limits<_t>::min();static const int64_t _max = (std::numeric_limits<_t>::max)();};
    #define _UINT_TRAIT(_t) template<> struct _type_parser_integral_traits<_t>{typedef std::true_type _is_integral;typedef std::true_type _is_unsigned;static const uint64_t _max = (std::numeric_limits<_t>::max)();};

    _INT_TRAIT(char)
    _INT_TRAIT(signed char)
    _INT_TRAIT(short)
    _INT_TRAIT(utf16char)
    _INT_TRAIT(int)
    _INT_TRAIT(long)
    _INT_TRAIT(long long)
    _UINT_TRAIT(unsigned char)
    _UINT_TRAIT(unsigned short)
    _UINT_TRAIT(unsigned int)
    _UINT_TRAIT(unsigned long)
    ......
    6 条回复    2014-08-10 21:27:35 +08:00
    heqing
        1
    heqing  
       2014-08-10 20:37:10 +08:00   ❤️ 1
    utf16char是什么,会不会与unsigned short重复了
    raincious
        2
    raincious  
    OP
       2014-08-10 20:38:49 +08:00
    @heqing

    看起来是个wchar_t。

    windows_compat.h这里定义的。

    typedef wchar_t utf16char;
    heqing
        3
    heqing  
       2014-08-10 20:45:31 +08:00   ❤️ 1
    再看一下wchar_t的定义
    raincious
        4
    raincious  
    OP
       2014-08-10 20:50:59 +08:00
    heqing
        5
    heqing  
       2014-08-10 20:56:23 +08:00   ❤️ 1
    Project Properties>C/C++/Language/Treat WChar_t as Builtin type, 试试这个
    raincious
        6
    raincious  
    OP
       2014-08-10 21:27:35 +08:00
    @heqing Passed。感谢。

    刚才在下curl耽搁了,好不容易下好之后立即试了这个解决方案,然后通过了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3235 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 12:16 · PVG 20:16 · LAX 05:16 · JFK 08:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.