c - 使用 Eclipse 在 C 中使用 malloc() 和其他函数

标签 c eclipse eclipse-plugin eclipse-cdt

这是我第一次使用 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;
}

当我将鼠标悬停在错误上时,它会显示以下内容:

Function 'malloc' could not be resolved.

我使用的是 malloc() 吗?

最佳答案

您没有提供足够的信息。您需要提供一个完整的程序,包括 malloc,无论多么小,都无法编译。您还需要给出您遇到的编译器错误,以及问题是出在 malloc 上还是出在所有标准库函数上。

据推测,您的编译器软件安装不正确,无法找到 stdlib.h

正如您现在添加的那样,没有标准库函数起作用,您的编译器设置肯定存在问题(这与 malloc 无关)。

关于c - 使用 Eclipse 在 C 中使用 malloc() 和其他函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15258926/

相关文章:

c - 我可以用枚举变量做什么?

c - 相当于 CUDA 类型转换内在函数 __double2loint、__double2hiint 和 __hiloint2double 的内在函数

python - eclipse 和红色 : unable to communicate with XML-RPC server

html - 让 Eclipse 突出显示和验证 HTML 文件

java - 如何获取 Eclipse DOM 插件开发类的 Javadocs?

css - 用于设计网页的eclipse插件

C - 将 9 转为 0

java - 将文本文件从 Java 服务器发送到 C 客户端

java - 如何以编程方式退出 Android 应用程序?

java - 在比较之前可以自动格式化源代码的差异工具?