Skip to content

Commit 6f4ee88

Browse files
committed
use MCX_CONTAINER and env macros to replace extra PYMCX_CONTAINER
1 parent cc723ff commit 6f4ee88

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ if (BUILD_PYTHON)
107107
ubj/ubjw.c
108108
pymcx.cpp
109109
)
110-
target_compile_definitions(pymcx PUBLIC PYMCX_CONTAINER)
110+
target_compile_definitions(pymcx PUBLIC MCX_CONTAINER)
111111

112112
target_link_libraries(pymcx OpenMP::OpenMP_CXX zmat ZLIB::ZLIB pybind11::module pybind11::lto pybind11::windows_extras)
113113

src/mcx_utils.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,11 @@ void mcx_initcfg(Config *cfg){
319319
memset(cfg->workload,0,MAX_DEVICE*sizeof(float));
320320
cfg->deviceid[0]='1'; /** use the first GPU device by default*/
321321
#if defined(MCX_CONTAINER)
322+
#ifndef PYBIND11_VERSION_MAJOR
322323
cfg->parentid=mpMATLAB;
323-
#elif defined(PYMCX_CONTAINER)
324+
#else
324325
cfg->parentid=mpPython;
326+
#endif
325327
#else
326328
cfg->parentid=mpStandalone;
327329
#endif
@@ -1087,7 +1089,7 @@ void mcx_flush(Config *cfg){
10871089
*/
10881090

10891091
void mcx_error(const int id,const char *msg,const char *file,const int linenum){
1090-
#if defined(MCX_CONTAINER) || defined(PYMCX_CONTAINER)
1092+
#ifdef MCX_CONTAINER
10911093
mcx_throw_exception(id,msg,file,linenum);
10921094
#else
10931095
MCX_FPRINTF(stdout,S_RED "\nMCX ERROR(%d):%s in unit %s:%d\n" S_RESET,id,msg,file,linenum);

src/mcx_utils.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,7 @@ extern "C"
316316
void mcx_matlab_flush(void);
317317
#endif
318318

319-
#ifdef PYMCX_CONTAINER
320-
#ifdef __cplusplus
321-
extern "C"
322-
#endif
323-
int mcx_throw_exception(const int id, const char *msg, const char *filename, const int linenum);
324-
#endif
325-
326-
#ifdef MCX_CONTAINER
319+
#if defined(MCX_CONTAINER) && defined(PYBIND11_VERSION_MAJOR)
327320
#ifdef _OPENMP
328321
#define MCX_FPRINTF(fp,...) {if(omp_get_thread_num()==0) mexPrintf(__VA_ARGS__);} /**< macro to print messages, calls mexPrint if inside MATLAB */
329322
#else

0 commit comments

Comments
 (0)