簡體   English   中英

在取消定義之前,將宏變量的值使用/復制到宏函數中/將其復制到宏函數中:是否可能?

[英]Using/Copying the value of a macro variable in/to a macro function before undefining it: is it possible?

如果我有:

#define A 1
#define B() A
#undef A

這段代碼:

#if B()
    std::cout << "B" << std::endl;
#else
    std::cout << "not B" << std::endl;
#endif

將打印“不是B”。 有沒有一種方法可以將A分配給另一個宏變量/函數,然后清除掉A?

背景:在cmake的configure_file上下文中使用 ,其中A是使用#cmakedefine01定義的。

沒有。

宏不是類,也不具有這種復雜性。

如果一個宏是用另一個宏定義的,則兩個宏都必須保留下來才能使替換正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM