c++ - Precompiled headers with GCC -


anyone had success getting precompiled headers working gcc? have had no luck in attempts , haven't seen many examples how set up. i've tried on cygwin gcc 3.4.4 , using 4.0 on ubuntu.

i have had success. first, used following code:

 #include <boost/xpressive/xpressive.hpp> #include <iostream>  using namespace std; using namespace boost::xpressive;  //a simple regex test int main() {     std::string hello( "hello world!" );      sregex rex = sregex::compile( "(\\w+) (\\w+)!" );     smatch what;      if( regex_match( hello, what, rex ) )     {         std::cout << what[0] << '\n'; // whole match         std::cout << what[1] << '\n'; // first capture         std::cout << what[2] << '\n'; // second capture     }     return 0; } 

this hello world boost xpressive (see below link). first, compiled -h option in gcc. showed enormous list of headers used. then, took @ compile flags ide (code::blocks) producing , saw this:

g++ -wall -fexceptions -g -c main.cpp -o obj/debug/main.o

so wrote command compile xpressive.hpp file exact same flags:

sudo g++ -wall -fexceptions -g /usr/local/include/boost/xpressive/xpressive.hpp

i compiled original code again -h , got output:

 g++ -wall -fexceptions -h  -g     -c main.cpp -o obj/debug/main.o ! /usr/local/include/boost/xpressive/xpressive.hpp.gch main.cpp . /usr/include/c++/4.4/iostream .. /usr/include/c++/4.4/x86_64-linux-gnu/bits/c++config.h .. /usr/include/c++/4.4/ostream .. /usr/include/c++/4.4/istream main.cpp 

the ! means compiler able use precompiled header. x means not able use it. using appropriate compiler flags crucial. took off -h , ran speed tests. precompiled header had improvement 14 seconds 11 seconds. not bad not great.

note: here's link example: http://www.boost.org/doc/libs/1_43_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.examples couldn't work in post.

btw: i'm using following g++

g++ (ubuntu 4.4.3-4ubuntu5) 4.4.3


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -