C Language
  • Reentrance
    • A reentrant function does not hold static data over successive calls, nor does it return a pointer to static data. All data is provided by the caller of the function. A reentrant function must not call non-reentrant functions.
    • A non-reentrant function can often, but not always, be identified by its external interface and its usage. For example, the strtok subroutine is not reentrant, because it holds the string to be broken into tokens. The ctime subroutine is also not reentrant; it returns a pointer to static data that is overwritten by each call.
  • Basic guidelines
    • Do not access mutable global or function-static variables.
    • Do not self-modify code.
    • Do not invoke another function that is itself non-reentrant.
  • type casting
  • C-style cast
  • typedef vs. define
typedef int *t1;
#define t2 int *

t1 a, b; /* a is 'int*' and b is 'int*' */
t2 c, d; /* c is 'int*' and d is 'int'  */
  • Conditional Compilation
#ifdef
#if defined (macro1)
2422521769_4f4c50c2f2.jpg
  • LP64 vs. LLP64: for LP64, long is 64 bits; for LLP64, long long is 64 bits
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License