This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
problem when returning a structure containing arrays.
- From: "Uwe Schmitt" <rocksportrocker at gmx dot de>
- To: <gcc at gcc dot gnu dot org>
- Date: Wed, 30 Aug 2006 21:32:55 +0200
- Subject: problem when returning a structure containing arrays.
Hi,
I compiled the follwing code with gcc -shared buglib.c -o buglib.dll:
>>> buglib.h is:
struct T
{
double x[256];
double y[256];
int i;
};
struct T fun(int a);
>>> buglib.c is
#include "buglib.h"
struct T fun(int a)
{
struct T retval;
int i;
for (i=0; i<256;++i)
{
retval.x[i]=(double)i;
retval.y[i]=(double)i;
}
return retval;
}
If I linkt this lib to
>>> main.c
#include <stdio.h>
#include "buglib.h"
int main()
{
struct T x = fun(1);
int i;
for (i=0; i<10; ++i)
printf("%d %d\n", x.x[i], x.y[i]);
}
Now the output is totally wrong !
I tried it with the cygwin port gcc 3.4.4 and with
gcc 3.3.1 on Suse Linux.
Any hints ?
Greetings, Uwe