Forum : ARM
Original Post
Post Information | Post |
---|---|
June 22, 2011 - 9:38pm
|
Hello, For example, I don't have type definitions such as the length of int, long, short and so on. I don't know how to declare a single bit variable. I use some things known from other compilers, but, I'm sure there are many things more dedicated to ARM. |
Hi,
In the "documentation" windows of Ride7 you will have plenty of inforamtion, including the gcc manual.
Also you can use the standard "limits.h" file, which will give you some information about the basic types size.
Notes:
Only "int" is questionable. The C standard mandates that:
- A short is 16-bit.
- A long is 32-bit.
The "char" type has no known sign. For safety it is always better to use "signed char" or "unsigned char" instead of plain "char".
Best Regards,
The gcc manual just help on using gcc and not having language keywords.
Can you tell me how to declare a one bit variable (boolean)?
I have a typedef enum{true=1,false=0} boolean
Does this create a one bit variable?
Hi,
Your declaration is just fine, if you really want to handle some bit-sized entities.
However, recall that the C language is pretty much centered about "O (zero)" and "not-zero" values, so it will always be better to handle values as 0 or not zero.
I.e., instead of "if (myvalue == true)", consider writing "if (!myvalue)". The readability is slightly decreased, but at least the generated code will be optimal.
This basically means that TRUE can be used for assignement only, but in comparisons only the FALSE value should be used.
Best Regards,