Here are my sources:
an_out = fopen ('foobar.h', 'w');fwrite (an_out, [ '#include <windows.h>', 10, 'int WINAPI foo (), bar ();', 10 ]);fclose (an_out);an_out = fopen ('foobar.c', 'w');fwrite... (an_out, ... [ ... '#include <windows.h>', 10, ... '_declspec (dllexport) int WINAPI foo (), WINAPI bar ();', 10, ... '#include "foobar.h"', 10, ... '_declspec (dllexport) int WINAPI foo () { return 0; } _declspec (dllexport) int WINAPI bar () { return 01; }', 10 ]);fclose (an_out);! CL /LD foobar.cloadlibrary foobar
MATLAB-generated thunk code causes the following compiler error:
foobar_thunk_pcwin64.c(25) : error C2143: syntax error : missing ')' before '('
Here is the relevant source:
#include "foobar.h"/* int __stdcall foo (), bar (); */EXPORT_EXTERN_C int32_T int32voidPtrbar(Thunk(void fcn(),const char *callstack,int stacksize){ void * p0; bar ( p1; p0=*(void * const *)callstack; callstack+=sizeof(p0) % sizeof(size_t) ? ((sizeof(p0) / sizeof(size_t)) + 1) * sizeof(size_t):sizeof(p0);
p1=*(bar ( const *)callstack; callstack+=sizeof(p1) % sizeof(size_t) ? ((sizeof(p1) / sizeof(size_t)) + 1) * sizeof(size_t):sizeof(p1);
return ((int32_T (*)(void * , bar ( ))fcn)(p0 , p1);}
You may wish to observe that the generated function declaration does not make sense.
Best Answer