From: Paul on 8 Jan 2010 16:42 Hi, I want to build up a mex function. I wrote a C function in Visual C 2008 and test it here. Everything was ok. After this I started Matlab, ran: mex - setup and set Visual C++ 2008 as the compiler. I made some tests with the Matlab test c files and no error. I tried to build my own function: ERROR!!! The error looks like: C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\cmath(21) : error C2143: syntax error : missing '{' before ':' C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\cmath(21) : error C2059: syntax error : ':' C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\cmath(21) : error C2143: and so on. In this file cmath (without extension) starting with line 18 one can find: 18: #ifndef RC_INVOKED 19: #if _GLOBAL_USING 20: _STD_BEGIN 21: using ::acosf; using ::asinf; 22: using ::atanf; using ::atan2f; using ::ceilf; 23: using ::cosf; using ::coshf; using ::expf; and so on First question is: why do I have this problem since I'm using the same compiler (in Visual Studio and in Matlab). And the second and much more important: how can I fix it??? Any suggestion is welcomed. Thanks a lot, Paul
From: James Tursa on 11 Jan 2010 10:04 "Paul " <paul_tutzu(a)yahoo.com> wrote in message <hif1sb$rkr$1(a)fred.mathworks.com>... > > I found the problem. > I saved the file as: file.c instead of file.cpp. It seems that the compiler is influenced by the file extension (C or C plus plus). I find this very stupid but what can I do. It is not stupid. Your MSVC is actually two compilers, a C compiler and a C++ compiler. These are two different languages with two different standards. The extension .c or .cpp tells MSVC which compiler to run. These are industry standard extensions and have very little to do with mex. James Tursa
|
Pages: 1 Prev: tick label in a polar plot Next: running simulink model in real time |