Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Compiler Error C2004

expected 'defined(id)'

An identifier must appear in the parentheses following the preprocessor keyword.

This error can also be generated as a result of compiler conformance work that was done for Visual Studio .NET 2003: missing parenthesis in preprocessor directive. If the closing parenthesis is missing from a preprocessor directive, the compiler will generate an error.

See Summary of Compile-Time Breaking Changes for more information.

The following sample generates C2004:

// C2004.cpp
// compile with: /DDEBUG
#include <stdio.h>

int main() 
{
    #if defined(DEBUG   // C2004
        printf_s("DEBUG defined\n");
    #endif
}

Possible resolution:

// C2004b.cpp
// compile with: /DDEBUG
#include <stdio.h>

int main() 
{
    #if defined(DEBUG)
        printf_s("DEBUG defined\n");
    #endif
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.