如何在C中定义arduino字节数组 [英] How to define arduino byte array in C
本文介绍了如何在C中定义arduino字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图移植以下代码:
I trying to port over the following code:
byte DIV_3_OF_5[8] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100
}; // 3 / 5
byte DIV_4_OF_5[8] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110
}; // 4 / 5
这个的C语法是什么,以及在这种情况下如何定义0和1?我需要将数字转换为十六进制吗?
我尝试过:
我试图将其迁移成功但没有成功。
What is the C syntax for this, and how to define 0s and 1s in this case? Do I need to convert the number to hex?
What I have tried:
I have tried to migrate it over without success.
推荐答案
一些编译器支持二进制文字,其中0b
或0B
前缀。它们不是C标准的一部分,但已经与C ++ 14一起引入。
如果你使用这样的编译器(例如GCC:使用GNU编译器集合(GCC):二进制常量 [ ^ ])插入零就足够了。如果没有,则必须将值转换为十六进制。
Some compilers support binary literals with a0b
or0B
prefix. They are not part of the C standard but has been introduced with C++14.
If you use such a compiler (e.g. GCC: Using the GNU Compiler Collection (GCC): Binary constants[^] ) it is sufficient to insert a zero. If not, you have to convert the values to hex.
这篇关于如何在C中定义arduino字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文