フィルターのクリア

loadlibrary produces invalid thunk code

2 ビュー (過去 30 日間)
Krzysztof
Krzysztof 2013 年 9 月 17 日
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.

採用された回答

Philip Borghesani
Philip Borghesani 2013 年 9 月 17 日
Although legal c this header code is certainly bad form and I would not recommend it. Unfortunately loadlibarary only properly recognizes one function deceleration per statement. I consider this a bug in loadlibrary please file a bug report.
To work around change
int WINAPI foo (), bar ();
Make it
int WINAPI foo ();
int WINAPI bar();

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by