<small id='ullVv'></small><noframes id='ullVv'>

    1. <tfoot id='ullVv'></tfoot>
    2. <legend id='ullVv'><style id='ullVv'><dir id='ullVv'><q id='ullVv'></q></dir></style></legend>

          <bdo id='ullVv'></bdo><ul id='ullVv'></ul>
        <i id='ullVv'><tr id='ullVv'><dt id='ullVv'><q id='ullVv'><span id='ullVv'><b id='ullVv'><form id='ullVv'><ins id='ullVv'></ins><ul id='ullVv'></ul><sub id='ullVv'></sub></form><legend id='ullVv'></legend><bdo id='ullVv'><pre id='ullVv'><center id='ullVv'></center></pre></bdo></b><th id='ullVv'></th></span></q></dt></tr></i><div id='ullVv'><tfoot id='ullVv'></tfoot><dl id='ullVv'><fieldset id='ullVv'></fieldset></dl></div>

        使用 GCC 预编译头文件

        时间:2023-09-19
          <bdo id='YRlly'></bdo><ul id='YRlly'></ul>

            • <legend id='YRlly'><style id='YRlly'><dir id='YRlly'><q id='YRlly'></q></dir></style></legend>
                  <tbody id='YRlly'></tbody>
                <tfoot id='YRlly'></tfoot>

                <small id='YRlly'></small><noframes id='YRlly'>

                <i id='YRlly'><tr id='YRlly'><dt id='YRlly'><q id='YRlly'><span id='YRlly'><b id='YRlly'><form id='YRlly'><ins id='YRlly'></ins><ul id='YRlly'></ul><sub id='YRlly'></sub></form><legend id='YRlly'></legend><bdo id='YRlly'><pre id='YRlly'><center id='YRlly'></center></pre></bdo></b><th id='YRlly'></th></span></q></dt></tr></i><div id='YRlly'><tfoot id='YRlly'></tfoot><dl id='YRlly'><fieldset id='YRlly'></fieldset></dl></div>

                1. 本文介绍了使用 GCC 预编译头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  有没有人成功地使用 GCC 获得预编译头文件?我的尝试没有运气,我没有看到很多关于如何设置它的好例子.我已经尝试过 cygwin gcc 3.4.4 并在 Ubuntu 上使用 4.0.

                  解决方案

                  我确实取得了成功.首先,我使用了以下代码:

                  <代码>#include #include 使用命名空间标准;使用命名空间 boost::xpressive;//一个简单的正则测试int main(){std::string hello( "hello world!" );sregex rex = sregex::compile( "(\w+) (\w+)!" );匹配什么;如果(regex_match(你好,什么,雷克斯)){std::cout <<什么[0]<<'
                  ';//整个匹配std::cout <<什么[1] <<'
                  ';//第一次捕获std::cout <<什么[2] <<'
                  ';//第二次捕获}返回0;}

                  这只是来自 Boost Xpressive 的一个 hello world(链接见下文).首先,我使用 gcc 中的 -H 选项进行编译.它显示了它使用的大量标题列表.然后,我查看了我的 IDE (code::blocks) 生成的编译标志,看到了如下内容:

                  g++ -Wall -fexceptions -g -c main.cpp -o obj/Debug/main.o

                  所以我写了一个命令来编译具有完全相同标志的 Xpressive.hpp 文件:

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

                  我用 -H 再次编译了原始代码并得到了这个输出:

                  <前>g++ -Wall -fexceptions -H -g -c main.cpp -o obj/Debug/main.o!/usr/local/include/boost/xpressive/xpressive.hpp.gch主程序./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主程序

                  !意味着编译器能够使用预编译的头文件.x 表示它无法使用它.使用适当的编译器标志至关重要.我取下 -H 并进行了一些速度测试.预编译的头文件从 14 秒改进到 11 秒.不错,但也不错.

                  注意:这是示例的链接:http://www.boost.org/doc/libs/1_43_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.examples 我无法让它在发布.

                  顺便说一句:我正在使用以下 g++

                  g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3

                  Anyone had any success getting precompiled headers working with GCC? I have had no luck in my attempts and I haven't seen many good examples for how to set it up. I've tried on cygwin gcc 3.4.4 and using 4.0 on Ubuntu.

                  解决方案

                  I have definitely had success. First, I used the 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] << '
                  '; // whole match
                          std::cout << what[1] << '
                  '; // first capture
                          std::cout << what[2] << '
                  '; // second capture
                      }
                      return 0;
                  }
                  

                  This was just a hello world from Boost Xpressive (see below for link). First, I compiled with the -H option in gcc. It showed an enormous list of headers that it used. Then, I took a look at the compile flags my IDE (code::blocks) was producing and saw something like this:

                  g++ -Wall -fexceptions -g -c main.cpp -o obj/Debug/main.o

                  So I wrote a command to compile the Xpressive.hpp file with the exact same flags:

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

                  I compiled the original code again with the -H and got this 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 that the compiler was able to use the precompiled header. An x means it was not able to use it. Using the appropriate compiler flags is crucial. I took off the -H and ran some speed tests. The precompiled header had an improvement from 14 seconds to 11 seconds. Not bad but not great.

                  Note: Here's the link to the example: http://www.boost.org/doc/libs/1_43_0/doc/html/xpressive/user_s_guide.html#boost_xpressive.user_s_guide.examples I couldn't get it to work in the post.

                  BTW: I'm using the following g++

                  g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3

                  这篇关于使用 GCC 预编译头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 OS X 中包含 omp.h? 下一篇:如何在我不想编辑的第 3 方代码中禁用来自 gcc

                  相关文章

                  最新文章

                  1. <tfoot id='IDjj9'></tfoot>
                  2. <legend id='IDjj9'><style id='IDjj9'><dir id='IDjj9'><q id='IDjj9'></q></dir></style></legend>
                      <bdo id='IDjj9'></bdo><ul id='IDjj9'></ul>

                  3. <i id='IDjj9'><tr id='IDjj9'><dt id='IDjj9'><q id='IDjj9'><span id='IDjj9'><b id='IDjj9'><form id='IDjj9'><ins id='IDjj9'></ins><ul id='IDjj9'></ul><sub id='IDjj9'></sub></form><legend id='IDjj9'></legend><bdo id='IDjj9'><pre id='IDjj9'><center id='IDjj9'></center></pre></bdo></b><th id='IDjj9'></th></span></q></dt></tr></i><div id='IDjj9'><tfoot id='IDjj9'></tfoot><dl id='IDjj9'><fieldset id='IDjj9'></fieldset></dl></div>

                    <small id='IDjj9'></small><noframes id='IDjj9'>