Source directory
| -- Stdafx. h
| -- Util directory
| -- Util. h
| -- Util. cpp
The definition of various variables of util. cpp is all red and wavy. The definition cannot be found, but can be compiled.
The problem lies in the first line in util. cpp.
# Include "stdafx. H"
In fact, this path cannot find the corresponding file, so we need to introduce stdafx. H to the project. The specific method is:
Properties-> Configuration properties-> C/C ++-> General-> additional include directories
Add $ (projectdir) to it.
Check macro and find that $ (projectdir) is the path pointing to the source directory, while stdafx. H files are located in this directory. Now there will be no problem of definition not found ~
Solve the problem where the. cpp file in the vs2010 subdirectory references stdafx. h In the upper-level directory and the definition cannot be found.