[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
precompiled headers and cygwin
From: |
JJ |
Subject: |
precompiled headers and cygwin |
Date: |
Sat, 30 Apr 2005 23:03:26 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041206 Thunderbird/1.0 Mnenhy/0.7 |
Is there a special trick to making precompiled headers work under CygWin?
I had read and followed the directions, but on testing I find that the
.h file is always used and the .h.gch is never used. These are the
directions I followed. The following directions are on the web but are
the same as the ones on my hard disk for my CygWin version of g++.
http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html#Precompiled%20Headers
Here's the general idea of how I tested it in pseudo code. (I just typed
the following from scratch without running it so it probably has typos
When I did the test, I didn't actually use a DOS batch file and I don't
actually have a program called 'replace.exe.' <G> I also didn't have any
comments in any of the files.)
======= example =======
//---------------------
// file: pre.h
#include <iostream>
const int a = 4;
//---------------------
// file: main.cpp
#include pre.h
using namespace std;
int main(){
cout << a << endl;
}
#----------------------
# file: makefile
main : main.o pre.h.gch
g++ main.o -o main
main.o : main.cpp pre.h
g++ -c main.cpp -o main.o
:gch
g++ -x c++ -c pre.h -o pre.h.gch
rem--------------------
rem file: test.bat
rem Update precompiled header and make.
make gch
make
rem prints 4
main
rem Edits pre.h to assign '2' to 'a.'
replace "pre.h" "4" "2"
rem Make without updating precompiled header.
make
rem Prints 4 if precompiled headers are working
rem or 2 if they are not working.
main
====== end example ======
When I run 'test,' it always prints 4 then 4 for me.
If precompiled headers were working, I would get 4
then 2.
Jeff
- precompiled headers and cygwin,
JJ <=