{"id":318,"date":"2012-08-28T11:37:24","date_gmt":"2012-08-28T15:37:24","guid":{"rendered":"http:\/\/zhanxw.com\/blog\/?p=318"},"modified":"2012-08-28T11:37:24","modified_gmt":"2012-08-28T15:37:24","slug":"gcc-%e7%9b%b8%e5%85%b3%e8%ae%be%e7%bd%ae%ef%bc%88%e8%b7%a8%e5%b9%b3%e5%8f%b0%e3%80%81%e4%b8%8d%e5%90%8c%e7%89%88%e6%9c%ac%ef%bc%89","status":"publish","type":"post","link":"https:\/\/zhanxw.com\/blog\/2012\/08\/gcc-%e7%9b%b8%e5%85%b3%e8%ae%be%e7%bd%ae%ef%bc%88%e8%b7%a8%e5%b9%b3%e5%8f%b0%e3%80%81%e4%b8%8d%e5%90%8c%e7%89%88%e6%9c%ac%ef%bc%89\/","title":{"rendered":"GCC \u76f8\u5173\u8bbe\u7f6e\uff08\u8de8\u5e73\u53f0\u3001\u4e0d\u540c\u7248\u672c\uff09"},"content":{"rendered":"<p>\u67e5\u770bgcc build-in specs<br \/>\n<code><br \/>\ngcc -dumpspecs<br \/>\n       -dumpspecs<br \/>\n           Print the compiler's built-in specs---and don't do anything else.  (This is used when GCC itself is being built.)<br \/>\n<\/code><\/p>\n<p>\u770bgcc\u5230\u54ea\u4e9b\u76ee\u5f55\u67e5\u627e\u5934\u6587\u4ef6\uff1a<br \/>\n<code><br \/>\ngcc -print-search-dirs<br \/>\n       -print-search-dirs<br \/>\n           Print the name of the configured installation directory and a list of program and library directories gcc will search---and don't do anything else.<\/p>\n<p>           This is useful when gcc prints the error message installation problem, cannot exec cpp0: No such file or directory.  To resolve this you either need to put cpp0 and the other compiler components where gcc expects to find them, or you can set the environment variable<br \/>\n           GCC_EXEC_PREFIX to the directory where you installed them.  Don't forget the trailing \/.<br \/>\n<\/code><\/p>\n<p>\u770bgcc\u7f16\u8bd1\u5230\u90a3\u4e2a\u5e73\u53f0<br \/>\n<code><br \/>\ngcc -Q -v<br \/>\n       -Q  Makes the compiler print out each function name as it is compiled, and print some statistics about each pass when it finishes.<br \/>\nzhanxw@host10-41.sph.umich.edu: ~\/temp> gcc -Q -v<br \/>\nUsing built-in specs.<br \/>\nCOLLECT_GCC=gcc<br \/>\nCOLLECT_LTO_WRAPPER=\/opt\/local\/libexec\/gcc\/x86_64-apple-darwin10\/4.7.1\/lto-wrapper<br \/>\nTarget: x86_64-apple-darwin10<br \/>\nConfigured with: ..\/gcc-4.7.1\/configure --prefix=\/opt\/local --build=x86_64-apple-darwin10 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=\/opt\/local\/lib\/gcc47 --includedir=\/opt\/local\/include\/gcc47 --infodir=\/opt\/local\/share\/info --mandir=\/opt\/local\/share\/man --datarootdir=\/opt\/local\/share\/gcc-4.7 --with-libiconv-prefix=\/opt\/local --with-local-prefix=\/opt\/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=\/opt\/local\/include\/gcc47\/c++\/ --with-gmp=\/opt\/local --with-mpfr=\/opt\/local --with-mpc=\/opt\/local --with-ppl=\/opt\/local --with-cloog=\/opt\/local --enable-cloog-backend=isl --enable-stage1-checking --disable-multilib --enable-lto --with-as=\/opt\/local\/bin\/as --with-ld=\/opt\/local\/bin\/ld --with-ar=\/opt\/local\/bin\/ar --with-bugurl=https:\/\/trac.macports.org\/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.1_2'<br \/>\nThread model: posix<br \/>\ngcc version 4.7.1 (MacPorts gcc47 4.7.1_2)<br \/>\n<\/code><\/p>\n<p>\u770bgcc\u9ed8\u8ba4\u5f00\u542f\u4e86\u54ea\u4e9bFLAG\uff08\u5b9a\u4e49\u4e86\u54ea\u4e9bmacro\uff09<br \/>\n<code><br \/>\n$cpp -dM <(echo \"\") \n#define __DBL_MIN_EXP__ (-1021)\n#define __FLT_MIN__ 1.17549435e-38F\n#define __DEC64_DEN__ 0.000000000000001E-383DD\n#define __CHAR_BIT__ 8\n#define __WCHAR_MAX__ 2147483647\n#define __DBL_DENORM_MIN__ 4.9406564584124654e-324\n#define __FLT_EVAL_METHOD__ 0\n#define __DBL_MIN_10_EXP__ (-307)\n#define __FINITE_MATH_ONLY__ 0\n#define __DEC64_MAX_EXP__ 384\n...\n...\n<\/code><\/p>\n<p>\u548cMacPorts \u76f8\u5173\u7684\u2014\u2014\u5982\u4f55\u9009\u62e9gcc<br \/>\n<code><br \/>\nsudo port select --list gcc<br \/>\nsudo port select --set gcc gcc42     # default gcc in Mac Snow Leopard<br \/>\nsudo port select --set gcc mp-gcc47  # MacPorts GNU GCC 4.7<br \/>\n<\/code><\/p>\n<p>\u548c\u5e73\u53f0\u76f8\u5173\u7684Macro\u5b9a\u4e49\uff1a<br \/>\n<a href=\"http:\/\/sourceforge.net\/apps\/mediawiki\/predef\/index.php?title=Operating_Systems\" title=\"Operation System Macros\"><\/a><\/p>\n<p>\u5176\u4ed6\u53c2\u8003<br \/>\n\u30101\u3011StackOverflow\u4e0a\u7684\u8ba8\u8bba\uff1a\u54ea\u4e2amacro\u53ef\u4ee5\u533a\u5206Mac\u548cLinux <a href=\"http:\/\/stackoverflow.com\/questions\/2565979\/macros-for-gcc-g-to-differentiate-linux-and-mac-osx\" title=\"Link\" target=\"_blank\">Link<\/a><br \/>\n\u30102\u3011SourceForge\u4e0aPre-defined C\/C++ Compiler Macros\uff0c\u5305\u62ec\u4ee5\u4e0b\u65b9\u9762\uff1a<br \/>\nStandards<br \/>\nCompilers<br \/>\nLibraries<br \/>\nOperating Systems<br \/>\nArchitectures<br \/>\nDevices<br \/>\n<a href=\"http:\/\/sourceforge.net\/apps\/mediawiki\/predef\/index.php?title=Main_Page\" title=\"Link\" target=\"_blank\">Link<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u67e5\u770bgcc build-in specs gcc -dumpspecs -dumpspecs Print the compiler&#8217;s built-in specs&#8212;and don&#8217;t do anything else. (This is used when GCC itself is being built.) \u770bgcc\u5230\u54ea\u4e9b\u76ee\u5f55\u67e5\u627e\u5934\u6587\u4ef6\uff1a gcc -print-search-dirs -print-search-dirs Print the name of the configured installation directory and a list of program and library directories gcc will search&#8212;and don&#8217;t do anything else. This is useful when [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[84,74],"class_list":["post-318","post","type-post","status-publish","format-standard","hentry","category-code","tag-cross-platform","tag-gcc"],"_links":{"self":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/comments?post=318"}],"version-history":[{"count":0,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/posts\/318\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/media?parent=318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/categories?post=318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhanxw.com\/blog\/wp-json\/wp\/v2\/tags?post=318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}