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 "Lefrancois, Carl" <Ca...@axa-canada.com> on 2008/04/21 15:25:49 UTC

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

Hi Alebu,
 
I may be mistaken, but there will be some type redefinition problems if
the struct is defined in a header that is included by many other files.
Is it possible to create an instance of the struct and use sizeof() on
that at run-time?  HTH
 
 

	-----Message d'origine-----
	De : alebu [mailto:aleboo@gmail.com] 
	Envoyé : lundi, avril 21, 2008 08:38
	À : Apache AXIS C User List
	Objet : 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.
  _____  

"Ce message est confidentiel, à l'usage exclusif du destinataire
ci-dessus et son contenu ne représente en aucun cas un engagement de la
part de AXA, sauf en cas de stipulation expresse et par écrit de la part
de AXA. Toute publication, utilisation ou diffusion, même partielle,
doit être autorisée préalablement. Si vous n'êtes pas destinataire de ce
message, merci d'en avertir immédiatement l'expéditeur."

"This e-mail message is confidential, for the exclusive use of the
addressee and its contents shall not constitute a commitment by AXA,
except as otherwise specifically provided in writing by AXA. Any
unauthorized disclosure, use or dissemination, either whole or partial,
is prohibited. If you are not the intended recipient of the message,
please notify the sender immediately."

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

Posted by Dimuthu Gamage <di...@gmail.com>.
Hi Kamath,
Adb headers already follow that and you will never get redefinition
problems including many of them.

Thanks
Dimuthu

On Mon, Apr 21, 2008 at 7:02 PM, Kamath, Navin <na...@iona.com> wrote:
>
>
>
>
> Hi,
>
>
>
> The right way to do it is to define it in a header file and provide header
> macro guards inside the header file
>
>
>
> #ifndef SOME_UNIQUE_IDENTIFIER
>
> #define SOME_UNIQUE_IDENTIFIER
>
>
>
> // struct defn
>
> //whatever else
>
>
>
> #endif /*SOME_UNIQUE_IDENTIFIER*/
>
>
>
> But I am new to Axis2 as well, so better wait for more comments from experts
> before implementing it rapidly
>
>
>
> Regards,
>
> Navin
>
>  ________________________________
>
>
> From: Lefrancois, Carl [mailto:Carl.Lefrancois@axa-canada.com]
>  Sent: 21 April 2008 14:26
>  To: Apache AXIS C User List
>  Subject: RE : WSDL2C: structure definition is generated in C file so sizeof
> fails compilation
>
>
>
>
>
>
>
> Hi Alebu,
>
>
>
>
>
> I may be mistaken, but there will be some type redefinition problems if the
> struct is defined in a header that is included by many other files.  Is it
> possible to create an instance of the struct and use sizeof() on that at
> run-time?  HTH
>
>
>
>
>
>
>
>
> -----Message d'origine-----
>  De : alebu [mailto:aleboo@gmail.com]
>  Envoyé : lundi, avril 21, 2008 08:38
>  À : Apache AXIS C User List
>  Objet : 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.
>
>
>
>
>  ________________________________
>
>
>
> "Ce message est confidentiel, à l'usage exclusif du destinataire ci-dessus
> et son contenu ne représente en aucun cas un engagement de la part de AXA,
> sauf en cas de stipulation expresse et par écrit de la part de AXA. Toute
> publication, utilisation ou diffusion, même partielle, doit être autorisée
> préalablement. Si vous n'êtes pas destinataire de ce message, merci d'en
> avertir immédiatement l'expéditeur."
>
>  "This e-mail message is confidential, for the exclusive use of the
> addressee and its contents shall not constitute a commitment by AXA, except
> as otherwise specifically provided in writing by AXA. Any unauthorized
> disclosure, use or dissemination, either whole or partial, is prohibited. If
> you are not the intended recipient of the message, please notify the sender
> immediately." ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>
>

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


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

Posted by "Kamath, Navin" <na...@iona.com>.
Hi,

 

The right way to do it is to define it in a header file and provide header macro guards inside the header file

 

#ifndef SOME_UNIQUE_IDENTIFIER

#define SOME_UNIQUE_IDENTIFIER

 

// struct defn

//whatever else

 

#endif /*SOME_UNIQUE_IDENTIFIER*/

 

But I am new to Axis2 as well, so better wait for more comments from experts before implementing it rapidly

 

Regards,

Navin

________________________________

From: Lefrancois, Carl [mailto:Carl.Lefrancois@axa-canada.com] 
Sent: 21 April 2008 14:26
To: Apache AXIS C User List
Subject: RE : WSDL2C: structure definition is generated in C file so sizeof fails compilation

 

Hi Alebu,

 

I may be mistaken, but there will be some type redefinition problems if the struct is defined in a header that is included by many other files.  Is it possible to create an instance of the struct and use sizeof() on that at run-time?  HTH

 

 

	-----Message d'origine-----
	De : alebu [mailto:aleboo@gmail.com] 
	Envoyé : lundi, avril 21, 2008 08:38
	À : Apache AXIS C User List
	Objet : 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.
	
	
	

________________________________

"Ce message est confidentiel, à l'usage exclusif du destinataire ci-dessus et son contenu ne représente en aucun cas un engagement de la part de AXA, sauf en cas de stipulation expresse et par écrit de la part de AXA. Toute publication, utilisation ou diffusion, même partielle, doit être autorisée préalablement. Si vous n'êtes pas destinataire de ce message, merci d'en avertir immédiatement l'expéditeur."

"This e-mail message is confidential, for the exclusive use of the addressee and its contents shall not constitute a commitment by AXA, except as otherwise specifically provided in writing by AXA. Any unauthorized disclosure, use or dissemination, either whole or partial, is prohibited. If you are not the intended recipient of the message, please notify the sender immediately." 


----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland