编译器警告(等级 1)C4047
“运算符”:“identifier1”与“identifier2”的间接级别不同
指针可以指向某个变量(一个间接级别),可以指向另一个指向某个变量的指针(两个间接级别),以此类推。
示例
以下示例生成 C4047:
// C4047.c
// compile with: /W1
int main() {
char **p = 0; // two levels of indirection
char *q = 0; // one level of indirection
char *p2 = 0; // one level of indirection
char *q2 = 0; // one level of indirection
p = q; // C4047
p2 = q2;
}
以下示例生成 C4047:
// C4047b.c
// compile with: /W1
#include <stdio.h>
int main() {
int i;
FILE *myFile = NULL;
errno_t err = 0;
char file_name[256];
char *cs = 0;
err = fopen_s(&myFile, "C4047.txt", "r");
if ((err != 0) || (myFile)) {
printf_s("fopen_s failed!\n");
exit(-1);
}
i = fgets(file_name, 256, myFile); // C4047
cs = fgets(file_name, 256, myFile); // OK
}
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈