Jump to content
OpenSplice DDS Forum
ianisM

Trouble with multi inclusion and idl preprocessor

Recommended Posts

HI,

I have multiple IDL files, lets says A.idl, C.idl D.idl, and all of these IDL have the same F.idl included at the top.

I have run the IDL preprocessor n all those files for a C standalone exit and do have all my *.c and *.h file.

The probleme occurs when I try to complie those .c and .h file I got a linker error dure to multiple declaration of type that where in the F.idl.

Howerver those .c and .h files seems to have multi-inclusion protection written by the preprocessor but they seem not to work at compilation.

Is there any way to generate those *.c and *.h file all together so the preprocessor implement working multi-iclution and multi-definition protection or do I have to try and correct them manually ? 

Share this post


Link to post
Share on other sites

Hi,

It might be an issue with anonymous types (that are deprecated in IDL 3) .. could you share an example that exhibits the issue ?

Share this post


Link to post
Share on other sites

sure that would be the definition of 

 struct T_IdentifierType
   {
       T_Int32 A_resourceIdentifier;
       T_Int32 A_instanceIdentifier;
   };

this definition is found in a IDL file that is included in all my other IDL files.

This strutc type is also used in all my other IDL files.

the problems appear to be with the __alloc and _alloc function of the DDS_sequence for that type.

in all of my *Dcps.h file that I got i have these lines that were generated :

DDS_sequence_P_LDM_Common_PSM_T_IdentifierType *DDS_sequence_P_LDM_Common_PSM_T_IdentifierType__alloc (void);
P_LDM_Common_PSM_T_IdentifierType *DDS_sequence_P_LDM_Common_PSM_T_IdentifierType_allocbuf (DDS_unsigned_long len);
#define P_HUMS_PSM_C_Monitored_Entity_sequence_P_LDM_Common_PSM_T_IdentifierType__alloc DDS_sequence_P_LDM_Common_PSM_T_IdentifierType__alloc
#define P_HUMS_PSM_C_Monitored_Entity_sequence_P_LDM_Common_PSM_T_IdentifierType_allocbuf DDS_sequence_P_LDM_Common_PSM_T_IdentifierType_allocbuf

 

and this is exactly what poses problem. Is there a way to regenerate those file without those multi-inclusion trouble or do I have to go and try to find a manual correction ?

Share this post


Link to post
Share on other sites

Looks like you are trying to use the GVA/LDM IDL files.

Could the problem maybe be that the LDM_Common idl file is missing include guards?

Share this post


Link to post
Share on other sites

Well it was my first tought but it indeed has the include guards. the other strange thing is that only those 2 would cause me trouble and not the other struct that were declared pretty much identically in those LDM_Common.IDL

Plus I did not wrote those IDL files, and I'm 100% not allowed to touch them or modify anything with them. I must do with whatever was given to me.

Anyway I solved my probleme by editing the generated h files and putting all the declaration of those problematic functions as inline.

Not pretty but it will do the trick untill I find a more elegant solution that does not require me tinkering with those generated files.

Share this post


Link to post
Share on other sites

The problem seems not to be in the include guard, because A.idl, B.idl and C.idl are all compiled independently. It is at link-time that you run into this issue since each compiled object file now has the same symbol. I will look into a way around this, but in the mean time you might want to circumvent the issue altogether by getting rid of the anonymous sequence, by putting a typedef in  the file that hosts your T_IdentifierType type, and then referring to that typedef from A.idl, B.idl and C.idl.

So as an example, let F.idl look like this:

struct T_IdentifierType
   {
       T_Int32 A_resourceIdentifier;
       T_Int32 A_instanceIdentifier;
   };

typedef sequence<T_IdentifierType> T_IdentifierTypeSeq;

And then use a reference to T_IdentifierTypeSeq in your other IDL files instead of using anonymous sequences there.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...