【发布时间】:2020-05-13 14:24:42
【问题描述】:
我有一个问题,我正在编写一个头文件,它根据 c 标准数据类型的大小定义不同的结构和联合。我需要这样的东西:
#if sizeof(int) == 4
typedef struct {
int i;
} test;
#else
typedef struct {
long i;
} test;
#endif
很遗憾,这不起作用。
有人知道吗,我该怎么做?
感谢您的帮助。
【问题讨论】:
-
#if INT_MAX == 2147483647...记得#include <limits.h>
标签: c c-preprocessor preprocessor