omnia neo said:
Thanks for the reply Yannick and all others..
well as was asked above here are some more claritis.
@Paul - I would have loved to put all compilable code but some code
cannot be just put on forums specially if it is some company's
proprietory.
@Anonmail - well I compiled all the code and also deleted the objects.
-I have both my structures in same header file so compilation unit
remains same.
-since both my structures are pretty complex (each one including
several different structures), it is difficult to know where the
arrays are used unappropriately.
For now I solved the issue this way(i still dont know the problem):
I replaced the placement of structure A in B as folows:
previous:
struct A
{
<other structures..its a huge list>
}
strcut B
{
struct A;
<other structures .. its a huge list again>
}
modified to:
struct A
{
<other structures..its a huge list>
}
strcut B
{
<other structures .. its a huge list again>
struct A;
}
With respect, I think you have serious problems in relation to your
understanding of your own code (or lack of it) and this is reflected in
your difficulty to communicate that here. For my part, I still do not
have the slightest sense of the aspects of it that you have tried to
convey so far. You will need to be more *precise*.
For instance, in the above pseudo-code your `struct A' within the
definition of B (in whatever order) is a *delaration* of a *type*, yet
you introduced your problem in terms such as "whenever I am trying to
add a *variable*..." Which is it? Are you having trouble with the
placing of local type declarations/definitions, data member positioning,
which?
Be sure of one thing. To say on the one hand "I still don't know the
problem" and then to suppose on the other that "I *solved* the issue
this way" is almost certainly a fallacy. C++ is not a `hold-my-hand'
language. It is possible in a myriad ways to write code that looks like
it `works', but unless you understand fully what that code achieves (and
how it achieves it) then the scope for merely seeming correctness is
vast. In short, drop the idea that you have *solved* anything. To have
`solved' something is to be able to say "I know this works, and I know
*how* this works."
You will need to present some *real* code here. I understand your point
about the need to protect proprietry code, and that is the same for
everyone here. Even where there is not such a requirement, there is
still the further `requirement' that the problem be condensed down to
some minimal example that illustrates the problem, which will mask any
proprietariness in any case.
Put something *else* together. Write a couple of small structs, A and
B, for which you can demonstrate that the placement of your `variables'
or the ordering of your declarations produces an effect the same as,
or similar to, that you are encountering for your codebase. Or, at the
very least, write them (in *actual* code, not pseudo-code) so that we
can get a picture of what you are working with with all the `vast'
aspects taken out, even if you can't recreate the failure. That way we
might be able to say something like "there's a pointer here, and here
you're using an unsafe cast (or something) ... /these/ are the kind of
pitfalls that you might encounter doing /that/." As it stands, I'm not
sure that anyone here has /any/ sense of what it is you are actually
doing.
Be *precise* about your descriptions. Don't just say "I replaced the
placement of structure A in B" because the word structure could be
referring to a declaration/definition of a type, as in:
struct A { };
or an instance of such a type, as in:
A a;
What is it that you have `moved'? Is it "I have reordered the data
members so that the member variable A a is now after..." or is it "I
have moved the declaration/definition of the local struct A to...?"
Also, I might have missed something, but you say "since both my
structures are pretty complex (each one including several different
structures), it is difficult to know where the arrays are used
unappropriately" and I hadn't picked up that you have mentioned *arrays*
previously.
Help us to help you! There are many people here who would welcome the
chance to do just that, given something to get started with.
Good luck.
Regards
Paul Bibbings