MSVC - include file anomolies
Microsoft Visual Studio C++ resolves include files in a non-intuitive manner.
There are two ways to augment MSVC's include path. The nasty way
it to hard code it in the Tools/Option/Diretcory control panel. This can cause
problems because it card codes C:\ ... in the path. However it does target all
projects. More flexible is to add /I directives in the C/C++ control panel.
However this has to be done for each project target.
Standard convention for most compilers when resolving a #include
is to look in standard system include directories before looking in a
project's custom include directories. Often this is explicitly set
up in the makefile for the project.
Under certain circumstances the MSVC Integrated Development Environment
(IDE) will NOT look in the standard system include directory first.
This situation arises when a custom header has the same name as a
standard system header AND the project's preprocessor settings have additional
include directories listed (e.g. /I fooinc). In this case the standard
header files that happen to have the same name as custom headers
will be incorrectly found first in the additional include directories.
Any code or definitions relying on the the proper standard header
file being processed will spaz out and often generate very misleading
compile error messages.
To resolve this, either rename your header file to something
more unique, or remove the project's preprocessor additional include
directories setting and hard code the source code to include
(e.g. #include "/fooinc/math.h")./* std C lib headers
* MSVC IDE will read these from its internally stored std include path */
#include <windows.h>
#include <stdlib.h>
#include <math.h> /* if /I fooinc set in project settings
this will be misread from fooinc/math.h */
#include <stdio.h>
#include <sys/timeb.h>
/* custom headers
* MSVC IDE will read these directly from current path */
#include "fooinc/cop.h"
#include "fooinc/math.h" /* custom header */
#include "fooinc/time.h"
#include "fooinc/class.h"