小编Ach*_*ogi的帖子

C V C++中的Typedef结构

这在C++中给出了错误,但在C中没有:

typedef struct nodes
{
    int data;
    struct node *next;
}node;
Run Code Online (Sandbox Code Playgroud)

它在C++中给出以下错误.

/home/DS cpp/linkedlist.cpp|10|error: conflicting declaration ‘typedef struct nodes node’|
/home/DS cpp/linkedlist.cpp|9|error: ‘struct node’ has a previous declaration as ‘struct node’|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Run Code Online (Sandbox Code Playgroud)

要使它在C++中工作,我必须将其更改为:

typedef struct node
{
    int data;
    struct node *next;
}node;
Run Code Online (Sandbox Code Playgroud)

我不明白为什么会发生这种情况,我想知道C和C++中的执行顺序,以便我能理解它.

c c++ struct typedef

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

如何删除更漂亮的分号?

我正在使用VS Code更漂亮的插件来格式化我的代码,在格式化代码时如何添加设置以不添加或删除分号?我知道这个功能是在1月份添加的,但我发现在PR或问题中没有提及如何将其添加到设置中.

javascript ecmascript-6 reactjs prettier

10
推荐指数
3
解决办法
7043
查看次数

标签 统计

c ×1

c++ ×1

ecmascript-6 ×1

javascript ×1

prettier ×1

reactjs ×1

struct ×1

typedef ×1