[ 
https://issues.apache.org/jira/browse/AXIS2C-750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539514
 ] 

Dimuthu Gamage commented on AXIS2C-750:
---------------------------------------

How Axis2/C core have solved the cyclic dependencies is different from the 
solution suggested by Michael (e.g. axis2_svc.h) . (Thanks Samisa for pointing 
that out)

foo.h

/* instead of #include bar.h it simply declare the struct */

struct bar;

typedef struct foo foo_t;

bar function();


bar.h

struct foo;

typedef struct bar bar_t

foo function(); 

So the user can include both foo.h and bar.h and get the work done.

Problem in this schema is that eventually the user need to include all the 
headers to their code to use these function. Or we may need to generate another 
header listing all the headers. For that we have to touch CStructWriter. :(

So I think the best way to get rid of this is to move typedefs above the 
#includes as suggested by Micheal. I would like to know whether there are any 
concerns on doing that. 

Thanks
Dimuthu

> Generated code will not build when there are cyclical header includes
> ---------------------------------------------------------------------
>
>                 Key: AXIS2C-750
>                 URL: https://issues.apache.org/jira/browse/AXIS2C-750
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: code generation
>    Affects Versions: 1.1.0
>         Environment: N/A
>            Reporter: Michael Mole
>            Priority: Minor
>
> If I have a schema that allows for cyclical dependencies, the generated adb 
> databindings will not build.
> For example, the generated code will look something like this:
> foo.h
> #include bar.h
> typedef struct foo foo_t;
> bar function();
> bar.h
> #include foo.h
> typedef struct bar bar_t
> foo function();
> This will not compile.  foo.h will try to include bar.h.  bar.h then tries to 
> resolve foo in the function declaration, but it cannot because foo has not 
> been defined yet.  This is because the typedef in foo.h comes after the 
> #include bar.h.
> To resolve this issue, I moved the typedefs ahead of the #includes.  The 
> generated code should do this to avoid this problem with cyclical 
> dependencies.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to