Different int sizes on my computer and Arduino

后端 未结 5 500
梦谈多话
梦谈多话 2021-01-21 07:12

Im working on a sparetime project, making some server code to an Arduino Duemilanove, but before I test this code on the controller I am testing it on my own machine (An OS X ba

5条回答
  •  不知归路
    2021-01-21 07:51

    The C standard defines an int as being a signed type large enough to at least hold all integers between -32768 and 32767 - implementations are free to choose larger types, and any modern 32-bit system will choose a 32-bit integer. However, as you've seen, some embedded platforms still use 16-bit ints. I would recommend using uint16_t or uint32_t if your arduino compiler supports it; if not, use preprocessor macros to typedef those types yourself.

提交回复
热议问题