Whilst most types are signed by default (short, int, long long), char is unsigned by default.
Because the natural data-size for an ARM processor is 32-bits, it is much more preferable to use int as a variable than short; the processor may actually have to use more instructions to do a calculation on a short than an int!
In code ported from other platforms, especially 8-bit or 16-bit platforms, the data types may have had different sizes. For example, int may have been represented as 16-bits. If this size has been relied on, some of the code may need updating to make it more portable. In addition, it is quite common that programmers will have defined their own types (UINT8, s8, BYTE, WORD, ..); it is probably beter to convert this to the stdint.h types, which will be naturally portable across platforms.
Where on the mbed web site can I find the various header files such as stdint.h, mbed.h, Serial.h etc?
I cannot be the only person who has searched (in vain) for them. Could Dan/Simon put a link to them on a handbook page? Links to the compiler and library documentation on the ARM web site would also be useful.
Where on the mbed web site can I find the various header files such as stdint.h, mbed.h, Serial.h etc?
I cannot be the only person who has searched (in vain) for them. Could Dan/Simon put a link to them on a handbook page? Links to the compiler and library documentation on the ARM web site would also be useful.
You can find (some of) them from the compiler by clicking on the mbed library in a program, then over on the right hand side click on Summary under Library Details and then "Open Library Page".
Hi Paul
You can find (some of) them from the compiler by clicking on the mbed library in a program, then over on the right hand side click on Summary under Library Details and then "Open Library Page".
For rev 28 for example, this takes you to http://mbed.org/projects/libraries/svn/mbed/trunk?rev=28
Regards\\
Daniel
Many thanks for this. All the mbed-specific header files seem to be there.
I guess the standard C/C++ header files are elsewhere. Does anybody know where?
Regards, Paul
Hi Daniel,
Many thanks for this. All the mbed-specific header files seem to be there.
I guess the standard C/C++ header files are elsewhere. Does anybody know where?
Regards,\\Paul
The standard headers are just that - standard. Their actual content doesn't matter much as long as you know that the compiler supports all the standard C and C++ features.
The standard headers are just that - standard. Their actual content doesn't matter much as long as you know that the compiler supports all the standard C and C++ features.
I wanted to see what pseudo-types (such as uint32_t) were available and how they were defined. Sure, I could Google it, but looking at the relevant header file seemed a good way of answering the question.
Have you never wanted to "look under the hood" in order to gain understanding of a subject?
I wanted to see what pseudo-types (such as uint32_t) were available and how they were defined. Sure, I could Google it, but looking at the relevant header file seemed a good way of answering the question.
Have you never wanted to "look under the hood" in order to gain understanding of a subject?
Hmm. I just got tricked while doing some fixed-point stuff.... I thought there was a long as in standard C, 64 bits. Just checked, and for whatever reason, long is only 32 bit. To get 64 bit ints you have to used long long... I only figured it out because I tested my code in Xcode.
Hmm. I just got tricked while doing some fixed-point stuff.... I thought there was a long as in standard C, 64 bits. Just checked, and for whatever reason, long is only 32 bit. To get 64 bit ints you have to used long long... I only figured it out because I tested my code in Xcode.
It would be *really* handy to have access to the versions of the standard libraries that are actually used in the mbed (as requested above). For example: mbed has char = unsigned. MS Visual Studio has char = signed. The standard says that char is implementation specific so really everyone must *always* specify the signedness of char or cast appropriately. I.e. saying "char str[2];" is asking for trouble. It should be "signed char" or "unsigned char" or "int8_t" or "uint8_t".
It would be *really* handy to have access to the versions of the standard libraries that are actually used in the mbed (as requested above). For example: mbed has char = unsigned. MS Visual Studio has char = signed. The standard says that char is implementation specific so really everyone must *always* specify the signedness of char or cast appropriately. I.e. saying "char str[2];" is asking for trouble. It should be "signed char" or "unsigned char" or "int8_t" or "uint8_t".
The ARM ABI defines char as an unsigned byte, and this is the interpretation used by the C++ libraries supplied with RVCT.
unsigned char is pretty much default on ARM. I'm not sure how knowing the library versions would help you there. The default compiler switches would be nice, yes.
From the link above:
<<quote>>
The ARM ABI defines char as an unsigned byte, and this is the interpretation used by the C++ libraries supplied with RVCT.
<</quote>>
##unsigned char## is pretty much default on ARM. I'm not sure how knowing the library versions would help you there. The default compiler switches would be nice, yes.
Posting new comments for this page has been disabled
Please login to post comments.