Report
5 years, 8 months ago.

What are the preferred data types for mbed libraries?

I'm writing/porting a CAN-BUS library for Seeed Studio's CAN-BUS shield and the FRDM-KL25Z system and I've noticed that the library functions that come with the mbed compiler typically use the 'fundamental' C data types, e.g. char, int, float etc. Is this the preferred way to go when writing for the mbed and as a second question why not use the C99 data types e.g. uint32_t which better describe the range of values that can be used? Thanks in advance, Sophie x

Comment on this question

1 Answer

5 years, 8 months ago.

See here. Technically, I don't think anything's stopping you from using the stdint types, but I've been using the 'fundamental' types to be consistent since that's what most mbed libraries use. One thing you should avoid doing is using integers smaller than 32-bits, the general consensus is that 8-bit or 16-bit integers may be bad for performance.

Hi Neil, thank you for your answer and for posting a link to the C Data Types page which I hadn't been able to find on my own. I will follow the mbed way for consistency and use int, char, float :-)

posted by Sophie Dexter 03 Oct 2013

To post an answer, please log in.