我查看了与我的问题匹配的问题,但找不到答案。在创建了一个程序来显示整数“i”和“k”的内存位置后,它没有使用 clang 编译。使用 SoloLearn 的 IDE 时,它运行良好。
#include <stdio.h>
void test(int k);
int main() {
int i = 0;
printf("The address of i is %x\n", &i);
test(i);
printf("The address of i is %x\n", &i);
test(i);
return 0;
}
void test(int k) {
printf("The address of k is %x\n", &k);
}
这些是我得到的错误。
memory.c:8:37: warning: format specifies type 'unsigned int' but the argument has type 'int *' [-Wformat]
printf("The address of i is %x\n", &i);
~~ ^~
memory.c:10:37: warning: format specifies type 'unsigned int' but the argument has type 'int *' [-Wformat]
printf("The address of i is %x\n", &i);
~~ ^~
memory.c:17:37: warning: format specifies type 'unsigned int' but the argument has type 'int *' [-Wformat]
printf("The address of k is %x\n", &k);
~~ ^~
3 warnings generated.
我需要在 int 上签名吗?如果需要,我应该怎么做?