I'm trying to compile a set of .c files from an open source project into a static library. I've created a VC++9 project file, set everything up as usual. I add two .c files into the project. They don't have any special compilation settings - all the settings are set at the project level and are set to default except that I turned off the precompiled headers.
I press "Build project" - VC++ says "Done", two .obj files and a .lib file are created but functions from one of the .c files are not present in the resulting .lib file.
If I add #error
at the very beginning of one of the two files VC++ stops compilation and reports. But if I do the same with the other file, it just silently compiles and doesn't report the error, so it obviously doesn't compile the file and that's why the functions don't get to the .lib file.
Now I suppose that if I add some text (like #error
) as the first line of a .c file the compiler would see it regardless of any preprocessor settings, compiler options, etc. Yet I have a file log.c
:
#error
whatever text follows
and Visual C++ reports:
1>------ Build started: Project: MyProject, Configuration: Debug Win32 ------
1>Compiling...
1>log.c
1>Build log was saved at "file://whatever\Debug\BuildLog.htm"
1>MyProject - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
What is happening to the compiler and how do I make it change its mind?