gpt4 book ai didi

c - 通过定义向结构体添加元素

转载 作者:太空宇宙 更新时间:2023-11-04 03:46:27 25 4
gpt4 key购买 nike

我有一个问题。我正在尝试通过先前定义的常量添加结构元素。这是示例代码(OpenGL+WinAPI)

#define ENGINE_STRUCT \
HGLRC RenderingContext;\
HDC DeviceContext;

然后:

typedef struct SWINDOW {

ENGINE_STRUCT

HWND Handle;
HINSTANCE Instance;
CHAR* ClassName;
BOOL Fullscreen;
BOOL Active;
MSG Message;
} WINDOW;

这可能吗?

最佳答案

是的,这是可能的,宏是一个简单的文本替换

http://www.cplusplus.com/doc/tutorial/preprocessor/

The preprocessor examines the code before actual compilation of code begins and resolves all these directives before any code is actually generated by regular statements.

关于c - 通过定义向结构体添加元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23968396/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com