gpt4 book ai didi

c - 定义一个引入一对变量的宏

转载 作者:行者123 更新时间:2023-11-30 20:16:21 27 4
gpt4 key购买 nike

有人可以帮我解决以下问题吗?

Define a macro which has the following prototype:

F(A, B, C, D)

After using this macro as F(name, float, a, b), you should be able to use the variables name.a and name.b. Make sure that your implementation is reusable, i.e you can use F more than once in the same block.

Also, extend it so that a predefined prefix is added to the variable. That is, if the predefined prefix is pt, then after using this macro, you should be able to usept_name.a, and pt_name.b.

Citrix 询问

最佳答案

这里:

#define F(name, type, var1, var2) struct {\
type var1 ;\
type var2 ;\
} name

这应该有效。

关于c - 定义一个引入一对变量的宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11312552/

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