سؤال

I need to compile a c++ (98. I cannot migrate yet to 11) code into a mex file.

Unfortunately after upgrading to Xcode 5.1 (which updated also Clang to 3.4 version) I cannot compile the code.

It is the same problem as in here: MEX compile error: unknown type name 'char16_t' Unfortunately the accepted answer is to compile with c++11 support which I cannot do.

Reading in the source code of Clang I found these lines:

// In C11 these are environment macros. In C++11 they are only defined
// as part of <cuchar>. To prevent breakage when mixing C and C++
// code, define these macros unconditionally. We can define them
// unconditionally, as Clang always uses UTF-16 and UTF-32 for 16-bit
// and 32-bit character literals.
Builder.defineMacro("__STDC_UTF_16__", "1");
Builder.defineMacro("__STDC_UTF_32__", "1"); 

Now.. I wonder why if they define the macro they do not define the type char16_t. And also... I cannot include (file not found) either cuchar (C++11) or uchar.h (C11)

Some idea on how to solve this problem?

EDIT: I'd like to understand if this is a bug of Clang (and I have to signal it) or not. According to C++11 standard (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2018.html) the marco __STDC_UTF_16__ should be defined in the header file cuchar. But I cannot find that file. So because of that I would expect that the macro is undefined. I think the MEX include file relies on this fact.

هل كانت مفيدة؟

المحلول

Just define char16_t (maybe CHAR16_T) as a macro somewhere in your code.

#define char16_t uint16_t

Or, pass -DCHAR16_T=uint16_t flag at compile time.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top