loadlibrary produces invalid thunk code
이전 댓글 표시
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.c
loadlibrary 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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!