MEX compile error: unknown type name 'char16_t

2019-01-13 11:21发布

I cannot compile any MATLAB MEX code due to the following error:

In file included from /Applications/MATLAB_R2013a.app/extern/include/mex.h:58:
In file included from /Applications/MATLAB_R2013a.app/extern/include/matrix.h:294:
/Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:819:9: error: unknown type name 'char16_t'
typedef char16_t CHAR16_T;

The only thing that has changed on my machine as far as I can remember is that Xcode was updated to version 5.1 (5B130a).

Any fix for the time being to compile MEX code in MATLAB?

[Running on OS 10.9.2 with Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)]

7条回答
成全新的幸福
2楼-- · 2019-01-13 11:40

I just add my own experiment (C++ only). The

#define char16_t uint16_t 

was causing some problem in the other parts of the mex file. In fact, subsequently to my mex file, char16_t was properly defined. By tracking the chain of includes, the proper type char16_t is set in a file named __config :

typedef __char16_t char16_t;

which is also the first file included from <algorithm>. So the hack consists in including algorithm before mex.h.

#include <algorithm>
#include "mex.h"

and the proper settings are performed, still in a multiplatform manner and without changing anything in the build configuration.

查看更多
登录 后发表回答