C99的inline用法和C++稍有不同,portable用法见Inline Functions In C
the xxx.h file:
#ifndef INLINE # if __GNUC__ && !__GNUC_STDC_INLINE__ # define INLINE extern inline # else # define INLINE inline # endif #endif INLINE int max(int a, int b) { return a > b ? a : b; }
the xxx.c file:
#define INLINE #include "xxx.h"
由于内存对齐,定义struct时应将成员从大到小排列最省空间