c - 在 C 中转换指针时出错

标签 c pointers casting compiler-errors

我有:

unsigned char *programBinary = (unsigned char) malloc(binarySize);

但我收到以下错误:

test.c:127:34: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
test.c:127:33: error: invalid type argument of unary ‘*’ (have ‘int’)

这对我来说是相当新的,所以我不确定如何解决这个问题。

最佳答案

您需要转换 (unsigned char*) 而不是 (unsigned char)

关于c - 在 C 中转换指针时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19988841/

相关文章:

C : Printing a pointer to an array seems to print a junk value also

c - 如何在 Linux 中的 C 程序中禁用中断

C 修改结构中的数组

c - fork 时,是否需要 'else' block ?

c# - LRESULT、WPARAM 和 LPARAM 是什么意思?

casting - 所有 32 位 float 都精确表示为 f64 吗?

c - 为什么这不写(接收)正确的字节数?

c - 指针数组内容在传递给 C 中的函数时被删除

python - 在 PySpark 中将多列转换为字符串的有效方法

c++ - 将基类指针转换为派生类指针