Hi,
I am writing an "hello world" program with a dll. I compile and test it with CodeWarrior and Carbide.
When I use the symbol exported by the .dll with a specific pattern, my program crashs. It does not reach the beakpoint I setup on the main() function: it crashs before the main() function. The pattern is this line:
where myvar is a variable exported by the dll and f is a local variable.PHP Code:mystruct_t *f[1] = {myvar};
If change this line with the 2 following lines, it works:
See the full sources below.PHP Code:mystruct_t *f[1];
f[0] = myvar;
Is it the expected behaviour, or a known bug?
testdll.c:
testexe.c:PHP Code:typedef char * (*ptrfunc_t)(char *);
struct mystruct_s
{
ptrfunc_t a;
ptrfunc_t b;
};
typedef struct mystruct_s mystruct_t;
__declspec(dllexport) char *func(char *a)
{
printf("func: '%s'\n", a);
sleep(5);
return "";
}
__declspec(dllexport) mystruct_t myvar[1] = {{func, func}};
ThanksPHP Code:typedef char * (*ptrfunc_t)(char *);
struct mystruct_s
{
ptrfunc_t a;
ptrfunc_t b;
};
typedef struct mystruct_s mystruct_t;
__declspec(dllimport) mystruct_t myvar[];
int main(int argc, char *argv[])
{
char *t;
mystruct_t *f[1] = {myvar};
/*
mystruct_t *f[1];
f[0] = myvar;
*/
printf("Hello world\n");
sleep(5);
return 0;
}

Reply With Quote


