[cfe-dev] error: cannot combine with previous 'type-name' declaration specifier

Sascha Wildner swildner at erpicon.de
Tue Jan 12 20:16:17 PST 2010

Am 11.01.2010 21:53, schrieb Douglas Gregor:
> On Jan 11, 2010, at 12:44 PM, Sascha Wildner wrote:
>> /usr/include/wchar.h:78:19: error: cannot combine with previous
>> 'type-name' declaration specifier
>> typedef __wchar_t       wchar_t;
>>                          ^
>> /usr/include/wchar.h:78:1: error: declaration does not declare
>> anything
>> typedef __wchar_t       wchar_t;
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> 2 diagnostics generated.
>> *** Error code 1
>> But what is the problem here?
> The wchar.h header looks suspicious. wchar_t is a built-in type in C+
> +, and cannot be a typedef.  Somehow, your wchar.h should protect
> against defining wchar_t when in C++ mode. I suggest looking through /
> usr/include/wchar.h to determine which preprocessor macros control
> that definition.

It turned out we didn't have #ifndef __cplusplus around our wchar_t 
typedef in wchar.h. With this being added, it at least gets through 
compilation but fails linking. I'm investigating currently and will get 
back in case I found something.

Just one note: gcc obviously doesn't have a problem with this (typedef 
wchar_t in C++). I've tried clang with -std=gnu++98 (gcc's default 
setting) but it didn't make a difference. Not sure if that qualifies as 
a "gcc compatibility bug" or so.

Thanks to all who answered,

More information about the cfe-dev mailing list