Visual Studio 2008 compiles anything in C++ file?
- by Brad Pepers
I noticed today that a source code file in a project was compiling even though it had junk at the top of it. It got me wondering what all would pass without error through the compiler. Here is an example of code that will not generate any error messages:
what kind of weird behaviour is this???
#include "stdafx.h"
// what is up?
int foo(int bar)
{
bla bla bla?????
return bar;
}
and more junk???
What in the world is the compiler doing to allow this code to compile without giving any error messages? I'm using Visual Studio 2008 and this is unmanaged C++ code. The foo function isn't actually generated in the object file so it can't be used but why no errors???