c - 简单 C 链表中的奇怪编译器错误

标签 c visual-studio-2010

我正在尝试用 C 语言编写链表。我正在使用以下代码:

#include <stdio.h>

typedef struct _node *nodep;
typedef struct _node {
    int value;
    nodep next;
} node;

int main(){
    printf("Hello World!");
    node* list = 0;
    return 0;
}

我得到一个编译器错误 C2275 和 C2065

    node* list = 0;

当我删除 printf 或将有问题的行移到 printf 之前时,代码会编译。

最佳答案

Visual Studio 不支持 C99。因此,您不能将声明和语句与此环境混合使用。而是写:

/* ... */

int main(void) {
    node *list = 0; /* declaration */
    printf("Hello World!\n"); /* statement */
    return 0;
}

符合 C89 标准。

关于c - 简单 C 链表中的奇怪编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17765332/

相关文章:

visual-studio-2010 - 如何将 Visual Studio 2010 解决方案设为只读?

visual-studio-2010 - VS2010 代码片段快捷方式未显示

在 C 中使用 regex.h 计算匹配数

c - 运行时检查失败 #2 - 变量 'd' 周围的堆栈已损坏

c - 1252-142 由于本地标签,AIX 汇编程序出现语法错误

C++ Visual Studio 2010 不链接 native 静态库

c++ - 如何使 c++ fstream 类引用在 Visual Studio 2010 CLR 中编译

c - C语言可以显示数组吗?

c - 无法链接 opencv 库

c++ - 想逐行阅读,但 fstream 只读第一行