gpt4 book ai didi

c - 有什么技巧可以禁止 C 宏被称为左值吗?

转载 作者:太空狗 更新时间:2023-10-29 17:04:46 24 4
gpt4 key购买 nike

例如,

struct node {
struct node *left, *right;
};
#define LEFT(X) (X->left)
#define RIGHT(X) (X->right)

我想在不改变现有宏接口(interface)的情况下禁止这样的宏调用。

LEFT(n) = ...

有什么想法吗?

最佳答案

试试这个:

#define LEFT(X) ((X)->left+0)
#define RIGHT(X) ((X)->right+0)

关于c - 有什么技巧可以禁止 C 宏被称为左值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5675817/

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