Search code examples
visual-c++pragmaprecompiled-headers

Disable language extensions, #ifndef fails


This question refers to Visual Studio C++ 2010. If I disable language extensions, even the simplest toy program gets an error of "unexpected end-of-file found" when I include even an empty .h file. It appears that the problem lies with the #ifndef HEADER_THING trick for not including a header twice. If I omit that, the error message goes away.


Solution

  • I found it by googling. It is a bug in VC++ 2010. The workaround is to add a newline after every #endif at the end of header files.

    http://connect.microsoft.com/VisualStudio/feedback/details/728179/unexpected-unexpected-end-of-file-found-found