Re: Definition order of POD
hurcan solter wrote:
I am generating a bunch of class type PODs from an xml file.The thing
is,xml file has no notion of order of definitions, so I end up in
situations like;
struct a
{
b bval;
};
struct b
{
int aval;
};
which wont compile because b is not yet defined when the compiler hits
it.
Yes, that code is invalid.
I also dont want to split them into different files because there are
numerous
and also like to provide to clients a single point of entry.
Even if you split them, you still need 'b' to be defined when 'a' is
being processed.
is there a
way to
avoid or circumvent this situation lest I should have to modify the
xml file itself?
Circumvent what exactly? The code as it stands, is invalid. There
is nothing that can be done to it, short of rewriting it to make it
valid.
How are you "generating" those PODs? Is that your C++ program or is
that something else, like a Perl script or a Python program? We can
only help with C++ code. When you generate those, you could try to
write the definition of 'a' and check if 'b' has been defined, and
if it hasn't, hold putting the definition of 'a' out until 'b' is
defined. But then you would be writing part of the compiler.
Fixing the program that produces your XML may actually be a more
viable solution.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask