(a) pch.h
// Solaris JUST includes this file.
#include 

(b) pch,cpp
// Visual C++ puts the start of this file into the
//				      precompiled header.
#define STR1 "Charlie "
#include "pch.h"
#define STR2 "Daniels"

(c) main.cpp
#include "pch.h"

#ifndef STR1
#  define STR1 "James "
#endif

#ifndef STR2
#  define STR2 "Brown"
#endif

int main()
{
    cout << STR1;
    cout << STR2;
    return 0;
}

Example 1: This program has different behaviors on NT and UNIX: (a) pch.h; (b) pch.cpp; (c) main.cpp.

Back to Article