Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » include *.pch
include *.pch [message #987268] Sun, 25 November 2012 07:45 Go to next message
Michael Mising name is currently offline Michael Mising name
Messages: 91
Registered: July 2009
Member
Hi
how to include a *.pch? (precompiled header?)
It should be loaded before other files?
Thanks
Re: include *.pch [message #987273 is a reply to message #987268] Sun, 25 November 2012 08:50 Go to previous messageGo to next message
Paul Bußmann is currently offline Paul Bußmann
Messages: 17
Registered: October 2012
Junior Member
Hi Michael,

if you search for "eclipse cdt pch", you get to http://www.eclipse.org/forums/index.php/mv/tree/148765/#page_top

Hope this helps. Smile

Best regards,
Paul
Re: include *.pch [message #987353 is a reply to message #987268] Mon, 26 November 2012 04:29 Go to previous messageGo to next message
Michael Mising name is currently offline Michael Mising name
Messages: 91
Registered: July 2009
Member
Thanks, but I saw that before. I'm looking for a simple g++ command line solution that I could simply paste into Eclipse properties. Also I only have the *.pch nothing else.
Re: include *.pch [message #987486 is a reply to message #987353] Mon, 26 November 2012 15:19 Go to previous messageGo to next message
Paul Bußmann is currently offline Paul Bußmann
Messages: 17
Registered: October 2012
Junior Member
The *.pch should only be created if the headers have changed, so I'd created a Makefile (precompiled.mk) for this purpose and add "make -f precompiled.mk" pre-build-command (only if the performance gain from the precompiled headers is more than you suffer from an additional make-invocation).
Would be cool to have a way to define generation rules for derived files and for sure, especially support for telling CDT to create and automatically update pch-files.
Re: include *.pch [message #987554 is a reply to message #987486] Tue, 27 November 2012 01:51 Go to previous messageGo to next message
Michael Mising name is currently offline Michael Mising name
Messages: 91
Registered: July 2009
Member
I'm not very experienced, so I wonder why I should bother about precompiled at all? Will the app run faster or only the compilation?
The file looks as below. How could I include that as normal header?
Many thanks

------------
/*
* stable.pch
* ToolSDL
*
* Created by Seb on 03/01/06.
* Copyright 2006 The Old Game Factory. All rights reserved.
*
*/
#ifdef __cplusplus
#ifndef __STABLE_PCH__
#define __STABLE_PCH__

///////////////////////////////////////////
// Standard headers

#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <limits>
#include <algorithm>
#include <fstream>
#include <istream>
#include <new>

using std::istream;
using std::ostream;
using std::ifstream;
using std::ios;
using std::flush;
using std::endl;
using std::cout;
using std::string;
using std::vector;
using std::map;
using std::numeric_limits;
using std::fill;


//////////////////////
// API headers

#include "OpenGL/glu.h" // Mac OS X OpenGL header location
//#include "GL/glu.h" // Other platforms OpenGL header location
#include "SDL.h"


//////////////////////////////////////////////////////
// Boost headers (cf. http://www.boost.org)

#include <boost/config.hpp>
#include <boost/shared_ptr.hpp>
using boost::shared_ptr;
#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
#include "boost/filesystem/fstream.hpp" // ditto
using boost::filesystem::path;
#include <boost/spirit/core.hpp>
#include <boost/spirit/utility/confix.hpp>
#include <boost/spirit/iterator/file_iterator.hpp>
#include <boost/spirit/symbols/symbols.hpp>



////////////////////////////////////////////
// Heavily shared & stable TooL headers

#include "Logger.hpp"


#endif //__STABLE_PCH__
#endif //__cplusplus

Re: include *.pch [message #987736 is a reply to message #987554] Tue, 27 November 2012 15:04 Go to previous message
Paul Bußmann is currently offline Paul Bußmann
Messages: 17
Registered: October 2012
Junior Member
If you don't change the *.hpp-files (e.g. Logger.hpp) corresponding to the *.pch-file than you don't have to bother with this at all.

See http://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc/Precompiled-Headers.html#Precompiled-Headers: "the compiler looks for a precompiled header in each directory just before it looks for the include file in that directory." .

You don't even *need* *.pch files. It's just to speed up compilation.

Hope this helps.
Previous Topic:do-while not work
Next Topic:getting started
Goto Forum:
  


Current Time: Sat Apr 19 21:59:53 EDT 2014

Powered by FUDForum. Page generated in 0.01884 seconds