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

17 views (last 30 days)
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.

Answers (1)

Geoff Hayes
Geoff Hayes on 8 Jul 2014
Try including two underscores in front of declspec
#define DLLEXPORT __declspec(dllexport)

Tags

Community Treasure Hunt

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

Start Hunting!