我最近把我的Mac升级到macOS Ventura,用自制软件把我的g升级到g-12。
但后来我发现我会得到error: unexpected token in '.section' directive
,而编译在这样的代码:
#include<vector>
#include<iostream>
using namespace std;
const int N=1e5+10;
vector<int> test[N];
int main(){
puts("Hello");
return 0;
}
通常可以编译。
我使用Vscode与coderunner附加。
我试着重新安装我的编译器并重新编译我的编译器。我认为这可能会有帮助,但实际上没有。
我搜索了互联网,但我发现没有解决这个问题,无论是在堆栈溢出。似乎每个人都有同样的问题,不使用C++。
我试着问我的老师和同学,但没有人知道为什么。
为什么会这样呢?先谢了。
下面是完整日志和详细输出
Using built-in specs.
COLLECT_GCC=g++-12
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/12.2.0/bin/../libexec/gcc/aarch64-apple-darwin22/12/lto-wrapper
Target: aarch64-apple-darwin22
Configured with: ../configure --prefix=/opt/homebrew/opt/gcc --libdir=/opt/homebrew/opt/gcc/lib/gcc/current --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-12 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 12.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --with-system-zlib --build=aarch64-apple-darwin22 --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Homebrew GCC 12.2.0)
COLLECT_GCC_OPTIONS='-v' '-std=c++14' '-Wall' '-o' 'test' '-mmacosx-version-min=13.0.0' '-asm_macosx_version_min=13.0' '-nodefaultexport' '-mlittle-endian' '-mabi=lp64'
/opt/homebrew/Cellar/gcc/12.2.0/bin/../libexec/gcc/aarch64-apple-darwin22/12/cc1plus -quiet -v -iprefix /opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/ -D__DYNAMIC__ test.cpp -fPIC -quiet -dumpbase test.cpp -dumpbase-ext .cpp -mmacosx-version-min=13.0.0 -mlittle-endian -mabi=lp64 -Wall -std=c++14 -version -o /var/folders/46/gnq0_xf15dj0d3drfw04nz7c0000gn/T//ccGl2TIh.s
GNU C++14 (Homebrew GCC 12.2.0) version 12.2.0 (aarch64-apple-darwin22)
compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../aarch64-apple-darwin22/include"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/local/include"
ignoring duplicate directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed"
ignoring nonexistent directory "/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/../../../../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../aarch64-apple-darwin22/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/aarch64-apple-darwin22
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/../../../../../../include/c++/12/backward
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include
/opt/homebrew/Cellar/gcc/12.2.0/bin/../lib/gcc/current/gcc/aarch64-apple-darwin22/12/include-fixed
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks
End of search list.
GNU C++14 (Homebrew GCC 12.2.0) version 12.2.0 (aarch64-apple-darwin22)
compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.25-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 1e863952a13ea06101beaf74284a4c21
COLLECT_GCC_OPTIONS='-v' '-std=c++14' '-Wall' '-o' 'test' '-mmacosx-version-min=13.0.0' '-nodefaultexport' '-mlittle-endian' '-mabi=lp64'
as -arch arm64 -v -mmacosx-version-min=13.0 -o /var/folders/46/gnq0_xf15dj0d3drfw04nz7c0000gn/T//ccCP1tBg.o /var/folders/46/gnq0_xf15dj0d3drfw04nz7c0000gn/T//ccGl2TIh.s
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1as -triple arm64-apple-macosx13.0.0 -filetype obj -main-file-name ccGl2TIh.s -target-cpu apple-m1 -target-feature +v8.5a -target-feature +fp-armv8 -target-feature +neon -target-feature +crc -target-feature +crypto -target-feature +dotprod -target-feature +fp16fml -target-feature +ras -target-feature +lse -target-feature +rdm -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -fdebug-compilation-dir=/Users/rogerlu/Desktop/Code/20221118/source/卢盛西 -dwarf-debug-producer "Apple clang version 14.0.0 (clang-1400.0.29.202)" -dwarf-version=4 -mrelocation-model pic --mrelax-relocations -mllvm -disable-aligned-alloc-awareness=1 -o /var/folders/46/gnq0_xf15dj0d3drfw04nz7c0000gn/T//ccCP1tBg.o /var/folders/46/gnq0_xf15dj0d3drfw04nz7c0000gn/T//ccGl2TIh.s
/var/folders/46/gnq0_xf15dj0d3drfw04nz7c0000gn/T//ccGl2TIh.s:477:29: error: unexpected token in '.section' directive
.section .data.rel.ro.local
^
1条答案
按热度按时间o0lyfsai1#
如果尝试使用g++,请添加以下选项:
-O2 -Wall -lm