运行:gcc版本4.2.1(苹果公司建立5664)慢编译时间与升压+ GCC +编译头
我创建了一个默认的预编译的头一个苹果XCode项目。它看起来非常慢,并且一个主要功能no的简单主文件包括无需编码需要6秒的编译,这是我升级到新的SSD驱动器后。我在笔记本电脑上,但我保留升级到工作站将缓解我的问题。如果我关闭预编译头文件,那么主文件将在一秒之内编译。看起来使用预编译头文件会对所有文件造成损失。这种延迟使我想避免编译和尝试不好的代码。这是我包括在我的预编译头文件中:
#pragma once
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <valarray>
#include <vector>
#include <boost/smart_ptr/scoped_ptr.hpp>
#include <boost/smart_ptr/scoped_array.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/shared_array.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#include <boost/regex.hpp>
#include <boost/thread.hpp>
#include <boost/bind/bind.hpp>
#include <boost/bind/apply.hpp>
#include <boost/bind/protect.hpp>
#include <boost/bind/make_adaptable.hpp>
#include <boost/asio.hpp>
//#include <boost/asio/ssl.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/random.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/local_time/local_time.hpp>
#include <boost/date_time/time_zone_base.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>
我没有包含精神,这确实会使编译时间上升。
因此,一个“主函数不重复的简单主文件不包含代码”比编译上述所有包含的项目花费的时间要少很多?这应该不是预期的吗? – jedwards
另外,我对预编译头文件的理解是,它们只是倾向于节省编译时间,否则它们会通过来自多个源的“include”重复编译。这不是你的情况,所以我想象你使用预编译头文件的编译时间会类似于没有。也就是说,通过使用预编译头文件你不会意识到很大的收获。你真的应该限制你的包含在源文件特定的基础上你需要什么。 – jedwards
这是什么意思:“这个延迟使我想避免编译和试验不好的代码。”? – jedwards