Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make my data types independent of compiler in c
    primarykey
    data
    text
    <p>I was studying uC/OS and read this article:</p> <blockquote> <p>Because different microprocessors have different <strong>word length</strong>, the port of μC/OS-II includes a series of type definitions that ensures portability Specifically, <strong>μC/OS-II’s code never makes use of C’s short, int and, long data types because they are inherently non-portable.</strong> Instead, I defined integer data types that are both portable and intuitive as shown in listing 1.1. Also, for convenience, I have included floating-point data types even though μC/OS-II doesn’t make use of floating-point. The following is listing 1.1</p> </blockquote> <pre><code>typedef unsigned char BOOLEAN; typedef unsigned char INT8U; typedef signed char INT8S; typedef unsigned int INT16U; typedef signed int INT16S; typedef unsigned long INT32U; typedef signed long INT32S; typedef float FP32; typedef double FP64; #define BYTE INT8S #define UBYTE INT8U #define WORD INT16S #define UWORD INT16U #define LONG INT32S #define ULONG INT32U </code></pre> <p>My questions is :</p> <p>1- What does the writer mean by word length(the first bold words in my question body) ?!</p> <p>2- Why short int and long data types are inherently non-portable.</p> <p>3- Is <code>typedef</code> is a microprocessor directive, and if it is what is its function ?!</p> <p>4- Can I write <code>typedef unsigned char (anything)</code> instead of <code>typedef unsigned char INT8U;</code></p> <p>5- Why did the author code <code>typedef unsigned char INT8U;</code> and then <code>#define UBYTE INT8U</code> can't I use this directly <code>typedef unsigned char UBYTE;</code></p> <p>6- There is a double use of <code>typedef unsigned char</code> one of them is <code>typedef unsigned char INT8U;</code> and the other <code>typedef unsigned char BOOLEAN;</code> Why did he do that?! </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload