大家好,我正在写一个需要使用无符号字符的程序。但是,每当我使用一个算术运算符或位运算符时,总是会得到“隐式签名到无符号转换”警告。结果是,在没有警告的情况下生成以下内容:例如:无符号CHAR测试(unChar char Test1,unChar TestStay2){Realth1(Test1)}我必须如下:无符号char测试(unChar char est1,unchar char est2){返回((unChar char)(TESTE1+Test2));}这不是必须的,不是吗?我唯一能想到的是,我的OrxC8项目已经设置了一些非常苛刻的语法设置。任何建议都将非常感激,因为不断地需要抛出这两个问题,并导致一些非常笨拙的源代码。格雷姆。
以上来自于百度翻译
以下为原文
Hi all,
I'm wri
ting a program which requires the use of unsigned chars. However, I'm constantly getting "implicit signed to unsigned conversion" warnings whenever I use an arithmetic or bitwise operator on one.
The result is that to get the following to build without a warning, for example:
unsigned char test(unsigned char test_1, unsigned char test_2) {
return (test_1 + test_2);
}
I have to cast as follows:
unsigned char test(unsigned char test_1, unsigned char test_2) {
return ((unsigned char)(test_1 + test_2));
}
This can't be necessary, can it? The only thing I can think is that I've got my project or XC8 set up with some extremely draconian syntax settings.
Any advice would be greatly appreciated as the constant need to cast is both concerning and leads to some very unwieldy source code.
Graeme.