VC++ F5 and Ctrl+F5, I'm mad...

Started by
20 comments, last by Hodgman 11 years, 7 months ago
Hi folks,

I'm stuck on a problem.. I wrote a OpenGL rendering framework using VC 2012. It loads model and shader files from hard drive. It works very well when I launch it by F5, BUT if I use Ctrl+F5, nothing is ever drawn on the screen.. Also under both 'modes', all files have been read in properly. I cannot figure out why, please help me if you have any ideas. Thanks in advance.

The libraries I used: glew 1.9, SDL 1.2, glm 0.9.3.4, C++11
Advertisement
Most likely you're relying on an uninitialized variable somewhere. Try turning the compiler's warning setting up to it's maximum level.
Do you use multi-threading or custom memory allocation?
Thanks for your answer Hodgman, regarding

Most likely you're relying on an uninitialized variable somewhere. Try turning the compiler's warning setting up to it's maximum level.

I maximized the warning levels but there are no variables uninitialized.


Do you use multi-threading or custom memory allocation?

Neither of them have been used so far. Though I found the rendering results may differ from time to time. E.g. very few times when I start the app only one of two meshes is drawn while other times nothing is drawn.
I maximized the warning levels but there are no variables uninitialized.
This just means there's no obvious uninitialized variables, there still might be some :/

e.g. This code creates a new uninitialized variable, but the compiler won't issue a warning about it:MyStruct* data = (MyStruct*)malloc( sizeof(MyStruct) );
Note that even without weird creation mechanisms, if you pass the address of an uninitialized variable around, MSVC won't give you a warning. Ex:

void foo1(int a) {}
void foo2(int * a) {}

int main(int, char **) {
int a;
int b;
foo1(a); // C4700
foo2(&b); // no warning
}
SiCrane - but that's normal usage of output argument. Why would you want warning for that? Then a lot of C style programs will give tons of warnings.
SiCrane did not say that should produce a warning. He said that is a situation where an uninitialized variable is used in a potentially dangerous context. That is an important point because the OP seems to assume no "uninitialized variable" warnings mean his program does not use them.
Try to use CppCheck on it, it's usually pretty good at founding uninitialised variables in C++, it has already saved my neck more than a couple of times since I've started using it.

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

The thing I don't get about the unitialized variable assumption ist that both F5 and Ctrl+F5 launch the debug build (one with debugger attached, the other without) so the variables that stay uninitialized in release but initialized in debug should be initialized as well. Or am I missing something?

Try to attach the debugger after launching with Ctrl+F5 maybe that helps in seeing what happens?
I have found the reason: there is a boolean member variable indicating the visibility of a mesh and it has not been initialized explicitly.. thus in debug mode (F5) it is initialized with 'true' otherwise it is random..
What confuses me is why VC initializes a boolean variable with 'true'?

This topic is closed to new replies.

Advertisement