Search code examples
c++allegro5

intelliSense: cannot open source file 'example.h'


I have a problem I can't get VS to open my header file although I have it added to my header file in my project

IntelliSense: cannot open source file "globals.h"

#include "globals.h"

Solution

  • In VS (2008 and newer):

    #include "path-spec"

    The path-spec is a file name optionally preceded by a directory specification. The file name must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.

    The preprocessor searches for include files in the following order:

    1. In the same directory as the file that contains the #include statement.
    2. In the directories of any previously opened include files in the reverse order in which they were opened. The search starts from the directory of the include file that was opened last and continues through the directory of the include file that was opened first.
    3. Along the path specified by each /I compiler option.
    4. Along the paths specified by the INCLUDE environment variable.

    The preprocessor stops searching as soon as it finds a file with the given name. If you specify a complete, unambiguous path specification for the include file between double quotation marks (" "), the preprocessor searches only that path specification and ignores the standard directories.

    If the filename enclosed in double quotation marks is an incomplete path specification, the preprocessor first searches the "parent" file's directory. A parent file is the file containing the #include directive. For example, if you include a file named file2 within a file named file1, file1 is the parent file.

    You can use the following syntax in VS if your folder with the header file is contained in your project:

    #include "foldername\\headerfile.h"