Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Firstly, thanks for reading.

I am in a conundrum, I need to call a data type which is declared in a file that is dynamically created.

I have a H file that is created dynamically from a WSDL file, it contains structure definitions for gSOAP communication from my client to the main server.

I now have to implement a new SOAP API call from within a Library process that uses one of the types in the H file, but the dynamic creation of the H file is after the compilation of the Libraries (which the new call is in).

The Libraries need to be compiled first for the rest of the program to work.

Which creates for me the problem of referencing a data type that is not only not defined, but the file in which it is defined does not exist yet, and I cannot create the file first as it requires the Libraries to compile that section.

1) Is there a way for me to use Extern or something similar to convince the compiler to not report a "incomplete type and cannot be defined" error and compile?

2) If not, do I need to change my build order somewhat?

3) Am I not doing something right to reach such a situation?

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 5-Jan-12 22:53pm    
Why? why?!
The main ideas of compilations are as simple as a brick. You can only use the types which are declared before the point of compiled line (in C++), period. How come you got lost so much? I don't know how to help you -- you did not share your idea. Writing client code using WSDL never causes any problems -- this is all about order of build steps which is written in declarative style in a build file.
--SA
Albert Holguin 7-Jan-12 20:59pm    
With gSOAP, just change your build order and remember you can have pre and post build events... that should help you be able to compile your code correctly.

No matter what, you must have to know the structure of your received data. It can be predefined or it can be described in SOAP structure.

In some cases function is written in such a way that it can return anything, pointer of array or pointer of structure or even long value. as example GetWindowLong function returns long, it can be a pointer or a long value. But whenever you will use them you must have to know what are you receiving.
 
Share this answer
 
1. You cannot compile incomplete code, therefore you must provide the full class definition before starting the compilation.

2. You can compile parts of your code with just a forward declaration if it abides by two rules:
a) you must know the exact name of the class (to make the forward declaration)
b) you may not access any members of the class, and you can only access pointer to class-type or reference to class-type variables - to create an instance in any way would require the full code of the class, so you can only shove around pointers and references, no more.

3. Most likely you're doing it wrong. But we can't tell without further information about why you need to dynamically create a type, and what you need to do with it. In any case, if you want to access functions of that class you must at the very least know the function definitions at that point, so you must have the class definition as well. OTOH if you don't have functions, then you don't need a (dynamically created) class at all, just a dynamic data structure - and that can be dealt with in other ways.

Your real conundrun is that you imply your code can sensibly access a type (or class) it doesn't know anything of - but how can it even refer to that class/type or members thereof if there is no definition at the time you write the code? You must already have some knowledge about the structure and design of that class/type just to be able to write that code that accesses it, so it cannot possibly be entirely dynamic.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900