出于某种原因,我正在使用 C++ 中的 exit() 函数。我的 mac running lion(64 位)出现各种奇怪的错误。我正在使用 g++ -o -g -Wall
进行编译.
图表 A:
#include <iostream>
int main(int arc, char *argv[]){
exit(1);
}
终端输出如下所示
$ g++ -o -g -Wall test main.cpp
ld: in test, can't link with a main executable for architecture x86_64
collect2: ld returned 1 exit status
但是$ g++ -o test main.cpp
编译正常。
使用 #include<stdio.h>
或 #include<stdlib.h>
导致相同的编译错误。
我只是想知道是否有人能够立即看到这里发生了什么?
最佳答案
test
是要生成的二进制文件的名称,您的第一个参数列表应该是:
> g++ -g -Wall -o test main.cpp
^^^^^^^ -o has test for an argument
关于c++ - 在 C++ 中使用 exit(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8089114/