预处理器使用#pragma指令定义



我想做一个包含#pragma指令的#define,但我得到了以下错误。知道吗?

#define FunctionPar_Begin  typedef struct fpar { #pragma pack(4)
error C2121: '#': invalid character: possibly the result of a macro expansion

您可能想要的:

#define FunctionPar_Begin  typedef struct fpar { _Pragma("pack(4)")

MSVC还允许:

#define FunctionPar_Begin  typedef struct fpar { __pragma(pack(4))

Clang/gcc还允许:

#define FunctionPar_Begin  typedef struct fpar { __attribute__((packed, aligned(4)))

最新更新