【发布时间】:2013-02-21 22:15:30
【问题描述】:
这是我第一次使用 Eclipse 编写 C 代码,所以答案可能很简单。我还认为 Eclipse 已经设置为可以适当地编译、构建和链接。这是在 Windows 7 64 位机器上运行的。
在我的 C 代码中,似乎每当我使用 malloc() 甚至 printf() 函数时,它都会在其下方放置红色波浪线。只是函数有下划线,而不是转换甚至参数。
下面是这行代码:
#include <stdlib.h>
#include <stdio.h>
int* list; //This is a global variable
int main(){
//...inside a function
list = (int*) malloc( sizeof(int) ); // Out of this line, only the word "malloc" is underlined in red.
printf(""); //printf also gives me an error
return 0;
}
当我将鼠标悬停在错误上时,它会显示以下内容:
函数“malloc”无法解析。
我什至使用malloc() 对吗?
【问题讨论】:
-
你还记得
#include <stdlib.h>吗? -
如果您正在编写 C(不是 C++),那么您做的不对 - Do I cast the result of malloc?
-
尝试编译时控制台窗口中的错误信息是什么?
-
我删除了我的答案,因为它只是值得评论,但我不知道,我一直被告知不要投我的
malloc的结果:int* list; list = malloc(sizeof(int)); -
你为什么不展示真实的代码,而不是强迫我们问明显的问题,或者猜测缺失的部分?
标签: c eclipse eclipse-plugin eclipse-cdt