運行: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