Skip to content

Latest commit

 

History

History
51 lines (44 loc) · 1.43 KB

compiler-warning-level-1-c4067.md

File metadata and controls

51 lines (44 loc) · 1.43 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 1) C4067
Compiler Warning (level 1) C4067
11/04/2016
C4067
C4067
1d10353e-8cd5-4b01-9184-a06189b965a4

Compiler Warning (level 1) C4067

unexpected tokens following preprocessor directive - expected a newline

Remarks

The compiler found and ignored extra characters following a preprocessor directive. This can be caused by any unexpected characters, though a common cause is a stray semicolon after the directive. Comments do not cause this warning. The /Za compiler option enables this warning for more preprocessor directives than the default setting.

Example

// C4067a.cpp
// compile with: cl /EHsc /DX /W1 /Za C4067a.cpp
#include <iostream>
#include <string> s     // C4067
#if defined(X);         // C4067
std::string s{"X is defined"};
#else
std::string s{"X is not defined"};
#endif;                 // C4067 only under /Za
int main()
{
    std::cout << s << std::endl;
}

To resolve this warning, delete the stray characters, or move them into a comment block. Certain C4067 warnings may be disabled by removing the /Za compiler option.

// C4067b.cpp
// compile with: cl /EHsc /DX /W1 C4067b.cpp
#include <iostream>
#include <string>
#if defined(X)
std::string s{"X is defined"};
#else
std::string s{"X is not defined"};
#endif
int main()
{
    std::cout << s << std::endl;
}