I am working on a backup time project by creating server code for the Arduino Duemilanove, but before testing this code on the controller, I test it on my own machine (MacBook based on OS X). I use ints in some places, and I am concerned that this will cause strange errors when the code is compiled and run on an Arduino Duemilanove, because Arduino treats ints as 2 bytes, and my macbook treats ints as 4 bytes. I'm not a hardcore C and C ++ programmer, so I'm a little worried about how an experienced programmer can handle this situation. Should I restrict the code with a typedef that includes my own definition and int that is limited to two bytes? Or is there another way?
It is best to use a title stdint.h. It defines typedefs that explicitly reference the signature and size of your variables. For example, a 16-bit unsigned integer is equal uint16_t. This is part of the C99 standard, so it is available almost everywhere. Cm:
stdint.h
uint16_t
http://en.wikipedia.org/wiki/Stdint.h
C , int , , , , -32768 32767 - , 32- 32- , , , - 16- int. uint16_t uint32_t, arduino ; , .
uint32_t
- , , :
int
long
long long
short
signed char
, (.. sizeof , ), .
sizeof
stdint.h , - . .
-32,768 , +32,767? , . , stdint.h , singned und unsigned, intN_t/uintN_t (N = ). C99, . , , , (16 ), , .
int, /.
short long
Source: https://habr.com/ru/post/1755622/More articles:SELECT / UPDATE and SELECT / INSERT kill MySQL server - phpBrowser based best practice MMO - pythonxhr with blackberry phone - cordovaКак я могу создать схему, которая требует определенных элементов, позволяет другим, и является агностиком порядка? - xmlprint groovy nodechild values - grailsSearch Keywords Using LINQ - c #If the Javascript code block is not at the end of the HTML file but uses jQuery $ (document) .ready (function () {...}), will this slow down the page display? - performanceBash script issue - scriptingHow can I get the occupied space using a java object in the memory heap? - javaВызов функции python через Интернет с помощью AJAX? - pythonAll Articles