![]() |
Structures via pointers giving different results to direct dot access
i can't figure this out.
This code: Code:
void __Eurofighter_construct(void * _eurofighter /* position, orientation */) { Code:
In __Eurofighter_construct. The structure ModelData is defined like this: Code:
typedef struct modelData { Code:
typedef struct bspModelData { Code:
static BSPModelData eurofighterBSPModelData = { Any ideas? |
Using a dot operator with a pointer requires you dereference using a star.
|
KPrintF(" eurofighterBSPModelData.modelData.numVertices = %d"
This should read %ld, like in the other places. The code is correct, the debugging isn't. |
Quote:
|
In case you missed my post: your code is doing what you expect. Your debug output is wrong.
|
Quote:
Code:
// but this doesn't: Thanks! |
Found it.
I had: Code:
Model * model = (Model *) model; Code:
Model * model = (Model *) _model; Code:
Model * wibble = (Model *) wibble; I think the best thing for me to do is to rework my variable naming to make this less likely to happen again. Edit: Code:
Model * wobble = wobble; |
C isn't picky. It just assumes you are right even if you aren't.
|
Quote:
The line is just a short form of Code:
Model *wibble; What you really should do is to avoid all that casting. Use proper types for your variables. For example in your first post instead of ModelData *m = (ModelData *) b; you should use ModelData *m = &b->modelData; This way the compiller can help you. If you use casting you tell the compiler that you know better than him. But obviously you don't. |
Quote:
|
Quote:
|
Quote:
|
All times are GMT +2. The time now is 18:59. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.