compiler-warnings 相关问题

编译器发出的消息,指示代码或配置中的潜在问题。

为什么printf(“%d”)没有可变的原因在c?

我错误地编写了此代码: #include int main(){ printf(“%d”); //缺少参数! 返回0; } 令人惊讶的是,它编译(存在警告),但是当我跑步时...

回答 1 投票 0





过时的成员使用情况

考虑这一堂课: 公共班级号 { [System.Obsolete()] public String toexActString()=>“”; [System.Obsolete()]公共覆盖字符串toString()=>”&...

回答 1 投票 0

插第错误的无需内部陈述警告?

Clang++(17.0.1)给出了此代码的警告: #include<< "fun\n"; } } // namespace template 名称空间{ void Fun() { std :: cout clang++(17.0.1)给出了此代码的警告:#include <iostream> namespace { void fun () { std::cout << "fun\n"; } } // namespace template<class T> void tfun (T) { fun(); } template<> void tfun (int); 如果不在匿名名称空间内,警告就会消失。 这是一个编译器错误? 请参阅Godbolt 这是一个令人讨厌的错误,但根据编译器(而不是编译器错误IMHO)仍然是一个错误。 从编译器POV,如果未启动模板函数fun,则该函数tfun在任何地方都不会使用。像fun都不在那里。 可能的修复方法是将模板进行tfun模板和实施,只有在实现fun时进行实例。这不是我喜欢的“修复”,但我不能更好地提出任何东西。 here是可编译的代码块: tfun

回答 1 投票 0


当启用C ++ 17更改为匹配C ++14

我的问题最少可复制示例Herey

回答 1 投票 0


为什么从超类调用final方法时会触发'this-escape'警告

Java 21 引入了一个新的 this-escape 警告,该警告针对构造函数调用可被子类重写的方法的情况发出警告。 这是一个潜在的危险情况

回答 1 投票 0

忽略空正文语句的警告

我希望当 if / else 语句的 else 为空时,android studio 不会标记为警告。 这是一个例子: 我一直在仔细观察偏好(/偏好/检查),但是我...

回答 1 投票 0

为什么java编译器不显示明显除以零的警告? [重复]

这只是我好奇为什么java编译器在这种情况下不显示任何警告,而它显示未经检查的操作的警告来预测可能的ClassCastException。 公开课

回答 1 投票 0

在英特尔编译器中的特定位置禁用警告

我有一个数学向量,我用模板参数 int N 定义其维度。问题是我在构造函数中添加了许多参数,最多 N=9,g++ 对此没问题,但是...

回答 2 投票 0

编译器未编译以下行(C++)

我在尝试编译此代码时遇到问题: int *array_aleatorio = new int[8]{0, 1, 2, 3, 4, 5, 6, 7}; 这是显示的错误: main.cpp:315:38: 错误:预期 ';'在

回答 2 投票 0

为什么Java不给出任何关于向下转型的警告?

我不明白Java编译器在认为可能成功时不警告向下转型背后的哲学。特别是,以下内容编译时没有任何警告(我是你...

回答 1 投票 0

从 DPR 文件中删除了编译器指令

问题 如何使编译器指令保留在 DPR 文件中? 描述 我需要关闭此编译器警告,因为我不打算使我的库与 C++ 兼容。 如果我把 co...

回答 2 投票 0

编译器指令从 Dpk 文件中删除

我需要关闭这个编译器警告,因为我不打算让我的库与 C++ 兼容。 如果我将编译器指令放入生成警告的 PAS 文件中,它将被忽略。 如果...

回答 2 投票 0

C 中的位字段访问

我正在尝试访问位字段: 下面的代码可以正常工作并给出预期结果,但会引发我在下面提到的编译器警告。 #包括 #包括 我正在尝试访问位字段: 下面的代码可以正常工作并给出预期结果,但会抛出我在下面提到的编译器警告。 #include <stdio.h> #include <stdint.h> struct status_type_one{ unsigned delta_cts : 1;// lsb unsigned delta_dsr : 1; unsigned tr_edge : 1 ; unsigned delta_rec : 1; unsigned cts : 1; unsigned dsr : 1; unsigned ring : 1; unsigned rec_line : 1;// msb } status_one; struct status_type_two { unsigned : 4; // lsb 4 bits unsigned cts : 1; //bit 5 unsigned dsr : 1; // bit 6 } status_two; int main(void) { status_one.delta_cts=1; status_one.delta_dsr=0; status_one.tr_edge=1; status_one.delta_rec=0; status_one.cts=1; status_one.dsr=0; status_one.ring=1; status_one.rec_line=1; printf("The value of status_one is %x\n",status_one); // warning here status_two.cts=1; status_two.dsr=1; printf("The value of status_one is %d\n",status_two); // warning here return 0; } 但我收到以下警告: $ gcc -Wall Bit_Fields.c -o Bit_Fields Bit_Fields.c: In function `main': Bit_Fields.c:35: warning: unsigned int format, status_type_one arg (arg 2) Bit_Fields.c:35: warning: unsigned int format, status_type_one arg (arg 2) Bit_Fields.c:40: warning: int format, status_type_two arg (arg 2) Bit_Fields.c:40: warning: int format, status_type_two arg (arg 2) 输出正确如下所示 $ ./Bit_Fields The value of status_one is d5 The value of status_one is 48 谁能告诉我这个警告是什么以及如何解决它吗? 谢谢 解决这个问题的典型方法是使用整数类型的联合值,例如: union status_type_one { struct status_type_one{ unsigned delta_cts : 1;// lsb unsigned delta_dsr : 1; unsigned tr_edge : 1 ; unsigned delta_rec : 1; unsigned cts : 1; unsigned dsr : 1; unsigned ring : 1; unsigned rec_line : 1;// msb } bits; unsigned whole[1]; // Size should match the total bits size. } status_one; 现在,您的其他代码必须更改: status_one.bits.delta_cts=1; status_one.bits.delta_dsr=0; status_one.bits.tr_edge=1; ... etc ... 和打印: printf("The value of status_one is %x\n",status_one.whole[0]); [显然,如果结构体整体上不止一项,则需要循环或将多个值传递给 printf] 您正在做的事情可能看起来很有效,但是您实际上不应该将 STRUCT 传递给 printf 函数,并且如果您使用多个机器字的数据,则无法知道它会做什么,或者在一个机器上会发生什么64位机等等等等

回答 1 投票 0

类型安全 - 为 varargs 参数创建通用数组 - 这是一个好的解决方案吗?

如果我向 JavaFX TableView 添加列: tableView.getColumns().addAll( col1, col2, col3 ); 我收到这个警告: 类型安全:为可变参数创建 TableColumn< T, ? > 的通用数组

回答 3 投票 0

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.