The error message “C2220: warning treated as error - no 'object' file generated” is output when the compiler option -WX is enabled and the code being compiled has a warning. When building with Platform Builder, the –WX compiler option is added when the environment variable WARNISERROR is set.
WARNISERROR is a handy environment variable for managing compiler warnings. With WARNISERROR set, warnings will cause the build to fail and therefore causes Software Engineers to clean up their code.
The error “C2220: warning treated as error - no 'object' file generated” will be output before the warning, so to find the cause of the error you must look down in the build output.
I wrote the following code to cause the error:
DWORD WarnIsError()
{
 
}
When built, the compiler outputs the following:
BUILD: [01:0000000034:ERRORE] c:\...\warniserror.c(33) : error C2220: warning treated as error - no 'object' file generated
BUILD: [01:0000000035:WARNN ] c:\...\ warniserror.c(33) : warning C4716: 'WarnIsError' : must return a value
So just for fun, I fixed that warning with:
DWORD WarnIsError()
{
                DWORD Variable;
 
                return Variable;
}
When built, the compiler outputs the following, as I expected:
BUILD: [01:0000000034:ERRORE] c:\...\ warniserror.c(34) : error C2220: warning treated as error - no 'object' file generated
BUILD: [01:0000000035:WARNN ] c:\...\ warniserror.c(34) : warning C4700: local variable 'Variable' used without having been initialized
These examples are simple, but they give you an idea about the value of WARNISERROR.
For more on the Platform Builder build system take a look at: Summary of Building Windows CE which lists the articles that I have written about building Windows CE using Platform Builder.
 
Copyright © 2009 – Bruce Eitman
All Rights Reserved