gpt4 book ai didi

c - C 编译错误

转载 作者:行者123 更新时间:2023-11-30 21:21:12 25 4
gpt4 key购买 nike

关闭。这个问题需要details or clarity .它目前不接受答案。












想改进这个问题?通过 editing this post 添加详细信息并澄清问题.

7年前关闭。




Improve this question




从昨天开始,我在 C 语言中遇到了一个烦人的问题,而你是我最后的希望……我对 C 编程并不陌生

我制作了一个包含 5 个 .c 文件及其标题的项目。
我的 .c 之一正在使用文件,因此在每个函数中我都有:

FILE* file = NULL;
file = fopen("xxx", "x");

显然,我包括了 sdtio 和 stdlib..
但是对于 gcc,我每次都有这些错误对于每个函数..
file_rw.c: In function ‘load_scramble’:
file_rw.c:9:9: error: ‘file’ undeclared (first use in this function)
FILE* file = NULL;
^

请帮忙 !
谢谢 :)

最佳答案

这似乎不太可能,但我能想到的一种可能性是有一些奇怪的宏代替了 FILE , 加上其他东西,这使得这个简单的声明不正确。您可以通过 gcc 找到预处理翻译单元的输出。与 -E标志(详见 man gcc)。

例如:

#include <stdio.h>

#define FILE

int main(void)
{
FILE* file = NULL;

return 0;
}

编译到 gcc出现以下错误:
prog.c: In function 'main':
prog.c:6:8: error: 'file' undeclared (first use in this function)
FILE* file = NULL;
^

关于c - C 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27891532/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com