Writing Portable Programs

  1. Size of Data Types
    1. Always use sizeof() to get the size of types(sizeof(char), sizeof(short), sizeof(int)...)
  2. Do not depend on the order of evaluation in an expression
  3. Char type may be singed or unsigned. Better to use an integer to store the output of getchar().
  4. Use standard Libraries
  5. Write platform-specific code is possible.

Reference from http://www.cs.princeton.edu/courses/archive/spring06/cos217/lectures/24portable.pdf

posted @ 2014-07-16 13:37  Sparkles  阅读(90)  评论(0编辑  收藏  举报