loadlibrary and preprocessor #define

9 views (last 30 days)
Tomas Björklund
Tomas Björklund on 12 May 2014
Hi!
My basic problem is that I cannot get loadlibrary to define a symbol to be set when parsing an .h-file. Is there any way to set such a define from Matlab that I have missed?
As a workaround I tried to make loadlibrary use a special .h-file that in itself set the defines like this and in turn includes the real .h-file:
// matlabIncludeFile.h
#define MATLAB_ONLY
#include "realIncludeFile.h"
// realIncludeFile.h
#ifdef MATLAB_ONLY
...
//What I want matlab to see
...
#else
...
//What I want all other compilers to see
...
#endif
But here it seems like a bug because realIncludeFile.h is parsed as if MATLAB_ONLY is not defined. If I move #define MATLAB_ONLY from matlabIncludeFile.h to realIncludeFile.h it works but that of course defeats my goal of having a specific define set when parsing via Matlab.
I have other options but they don't appeal to me for various reasons such as:
  • Different include directories for matlab and not-matlab parsing
  • A #ifndef and compiler constant in commandline of all other compilers.
Any suggestions to solve my original problem? For example, does Matlab set up a specfic predefined macros such as GCC's _GNUC_?

Answers (0)

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!