[cfe-dev] [libc++] Conflict between "_UI" template parameter and Windows tchar.h macro

Orivej Desh via cfe-dev cfe-dev at lists.llvm.org
Mon May 29 19:45:59 PDT 2017


At present `algorithm' and `random' can not be included after `tchar.h' [1]
because it contains

     #define _UI     unsigned int

and the former contain templates like

     template <class _UI, _UI _Xp> struct __log2

that fail to compile with

     algorithm:2807: error C2332: 'class': missing tag name
     algorithm:2807: error C2628: '<unnamed-tag>' followed by 'unsigned' is illegal (did you forget a ';'?)
     algorithm:2807: error C2628: '<unnamed-tag>' followed by 'int' is illegal (did you forget a ';'?)
     algorithm:2807: error C2993: '': illegal type for non-type template parameter '<unnamed-tag>'

This affects compilation of open source libraries, in particular this
BDB file [2] fails to compile because it includes tchar.h [3] before C++
STL.  What is the best way to resolve this?  May libc++ rename or
undefine `_UI'?

[1] This one is from the old vc6 crt library, but Visual Studio 2017
    installs crt with the same macros:
    https://github.com/weolar/miniblink49/blob/f3ffb1ee/vc6/include/crt/tchar.h#L838
[2] https://github.com/berkeleydb/libdb/blob/master/lang/cxx/cxx_seq.cpp
[3] https://github.com/berkeleydb/libdb/blob/master/src/dbinc/win_db.h#L33



More information about the cfe-dev mailing list