필터 지우기
필터 지우기

error: expected constructor, destructor, or type conversion before '(' token?

조회 수: 16 (최근 30일)
margol
margol 2014년 7월 7일
답변: Geoff Hayes 2014년 7월 8일
I'm trying to compile a cpp file using mex (changeanalysis.cpp). I have Matlab R2012a, Xcode 4.6 on a MAC OS X 10.7. In the file changeanalysis.cpp, aef_global_dllexport.h is included. Some part of aef_global_dllexport.h is as follows:
////////////////////////
// DLL EXPORT FUNCTIONS
////////////////////////
#define DLLEXPORT _declspec(dllexport)
DLLEXPORT double maha_dist_3D_ex( double x,
double y,
double z,
double* mean,
double** icovm);
DLLEXPORT int matrix_inv_ND_ex( double** matND,
double& det,
int Dim);
DLLEXPORT int matrix_copy3x3_ex( double** x,
double** y);
.
.
.
When I compile the file changeanalysis.cpp, I get the following error message at the command prompt:
mex -I"/Users/marzi/Documents/MATLAB" changeanalysis.cpp
In file included from changeanalysis.cpp:58:
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:7: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:13: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:17: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:20: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:22: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:24: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:29: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:31: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:50: error: expected constructor, destructor, or type conversion before '(' token
/Users/marzi/Documents/MATLAB/aef_global_dllexport.h:75: error: expected constructor, destructor, or type conversion before '(' token /Users/marzi/Documents/MATLAB/aef_global_dllexport.h:100: error: expected constructor, destructor, or type conversion before '(' token
mex: compile of ' "changeanalysis.cpp"' failed.
Error using mex (line 206) Unable to complete successfully.
Does anyone know how to fix this or what is the cause of this error?
Thanks.

답변 (1개)

Geoff Hayes
Geoff Hayes 2014년 7월 8일
Try including two underscores in front of declspec
#define DLLEXPORT __declspec(dllexport)

카테고리

Help CenterFile Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by