相关疑难解决方法(0)

为什么有些编译器使用"a.out"作为可执行文件的默认名称?

大多数UNIX C编译器默认情况下将可执行文件链接到名为"a.out"的文件.为什么?这是书面标准还是事实上的标准行为?如果这些编译器只生成错误消息(或使用不同的默认名称)而不是生成"a.out",会破坏什么?

c unix compiler-construction history

25
推荐指数
2
解决办法
9804
查看次数

Clang的-Wall和-Wextra中包含哪些警告?

我发现Clang的文档很差.我找不到很多可用的Clang警告标志列表.我特别感兴趣的是C/C++警告,但这是一个普遍的问题.

GCC列出并描述了警告,并列出了-Wall和-Wextra中包含的内容:https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options

Clang的-Wall和-Wextra包含哪些警告标志?

我可以为每个版本搜索Clang发行说明,以查看每次引入的新警告标记(例如http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html),但是更容易列表和/或描述Clang的警告?这将非常有用.我需要知道-Wall包含哪些内容,哪些不包含,所以我可以考虑启用那些不包含的内容.

(我知道 - 对于Clang来说存在一切 - 我可能不得不求助于使用它而只是明确禁用我不喜欢的那些吗?更多文档会使这更理想.)

c c++ clang compiler-warnings

21
推荐指数
2
解决办法
1万
查看次数

尝试在C++中使用结构时出错

我正在尝试低估如何在C++中使用结构作为列表.我提出了一段代码,对我来说,这不应该导致任何错误,但它确实......

我的代码是这样的:

struct item {
int data;
struct item *next;
};

struct item *begin = NULL;

void add(int x) {
    struct item *a = new struct item();
    a->data = x;
    a->next = begin;
    begin = a;
}

int main() {

    add(2);
    printf("%d\n", begin->data);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

它给了我这个:

Undefined symbols for architecture x86_64:
"operator new(unsigned long)", referenced from:
  add(int) in structtest-f49486.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see …
Run Code Online (Sandbox Code Playgroud)

c++ struct

3
推荐指数
1
解决办法
132
查看次数

我的代码有问题吗?我该如何解决?

#include <iostream>
 void dummyfunction(void)
 {
     std::cout<< "this is";
 }
Run Code Online (Sandbox Code Playgroud)

错误:

#include <iostream>
 void dummyfunction(void)
 {
     std::cout<< "this is";
 }
Run Code Online (Sandbox Code Playgroud)

。我该如何解决?

c++ macos

-5
推荐指数
1
解决办法
70
查看次数