C 语言笔记

技巧

  1. 为什么自我定义: 便于条件编译

enum {
    SOCK_CLOEXEC = 1
#define SOCK_CLOEXEC SOCK_CLOEXEC
};

#ifdef SOCK_CLOEXEC
    flags = SOCK_CLOEXEC;
#endif
  1. 开启编译警告

-Wall
-Wextra
-pedantic/-Wpedantic
-Weverything (clang only)