I have a structure definition that looked like this:
struct mystruct
{
int first;
int second;
};
I have recently updated it, adding more members:
struct mystruct
{
int first;
int additional1;
int additional2;
int second;
};
I am debugging code that looks like this:
mystruct object;
...
object.second = 128;
printf("%d\n", object.second);
After executing the code, i look at object.second in the Quick-Watch window and see 0; however, the code outputs 128. When i look at object, i see only first and second members, as if the Quick-Watch window still used my old structure declaration.
In addition, the address of object.second, if i print it from the code, is different from what i see in the Quick-Watch window if i enter &object.second there (off by a few words; my structure actually contains dozens of members, which i omitted for brevity).
I tried to fix these incompatibilities by recompiling, rebooting, reverting the recent change (i use a version control system) and returning it. What else can i try to fix this problem?
I use MS Visual Studio 2005. My code is actually C++ but this part belongs to the C/C++ common subset.
When you write mystruct object; it works on Visual Studio 2005 but the proper way to write it when you use normal struct decleration and not using a typedef needs to be struct mystruct object; as explained here.
I'm not sure if that is the thing that bugged you, but give it a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With