You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by alebu <al...@gmail.com> on 2008/04/21 14:38:19 UTC

WSDL2C: structure definition is generated in C file so sizeof fails compilation

Hi, I am generating web service using WSDL2C. In generated code I got such a
division of sources:
In header (.h) file i got type declaration like:
typedef struct adb_my_type adb_my_type_t;

But adb_my_type structure is located in source file (.c):
struct adb_my_type {
   // declaration of my_type
};

Such a location of sources creates a problem when I trying to allocate
memory for such a structure.
sizeof(adb_my_type_t) fails with incomplete type ...
As I understand, it happens because compiler can't discover exact size of
structure from header, because actual information
is available only from source file.
I moved declaration to header like:
struct adb_my_type {
   // declaration of my_type
};
typedef struct adb_my_type adb_my_type_t;

And now everything works fine, so I think that it is better to generate code
in such way.
Or maybe there is some motivation to do it like it is made for now?
If so, then what is that motivation? And how then to get size of structure?
I think It is code generator bug so thats why I actually write that letter.

Re: WSDL2C: structure definition is generated in C file so sizeof fails compilation

Posted by Dimuthu Gamage <di...@gmail.com>.
Hi alebu,
It is really encouraged to use adb_my_type_create instead of
explicitly using malloc to create the adb objects. I think create/free
function should be completely able to fulfill your needs in managing
object life.

Thanks
Dimuthu

On Mon, Apr 21, 2008 at 6:08 PM, alebu <al...@gmail.com> wrote:
> Hi, I am generating web service using WSDL2C. In generated code I got such a
> division of sources:
> In header (.h) file i got type declaration like:
> typedef struct adb_my_type adb_my_type_t;
>
> But adb_my_type structure is located in source file (.c):
>  struct adb_my_type {
>    // declaration of my_type
> };
>
> Such a location of sources creates a problem when I trying to allocate
> memory for such a structure.
> sizeof(adb_my_type_t) fails with incomplete type ...
>  As I understand, it happens because compiler can't discover exact size of
> structure from header, because actual information
> is available only from source file.
> I moved declaration to header like:
> struct adb_my_type {
>     // declaration of my_type
>  };
> typedef struct adb_my_type adb_my_type_t;
>
> And now everything works fine, so I think that it is better to generate code
> in such way.
> Or maybe there is some motivation to do it like it is made for now?
> If so, then what is that motivation? And how then to get size of structure?
>  I think It is code generator bug so thats why I actually write that letter.
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org