这在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++中的执行顺序,以便我能理解它.
我正在使用VS Code更漂亮的插件来格式化我的代码,在格式化代码时如何添加设置以不添加或删除分号?我知道这个功能是在1月份添加的,但我发现在PR或问题中没有提及如何将其添加到设置中.