-2
Can a Macro with a goto statement and a label be defined?可以定义具有goto语句和标签的宏吗?
Can a Macro with a goto statement and a label be defined?可以定义具有goto语句和标签的宏吗?
宏是一个文本替换由预处理器照顾,所以,你可以。您可以为goto语句和/或标签定义一个maro。
Ps。反正是一个可怕的做法..使用大量的宏和使用goto方法
#include <iostream>
#define GOTOSTMT goto helloworld;
#define LABELSTMT helloworld:
int main() {
int i = 0;
LABELSTMT
std::cout << "Don't ever program like this" << std::endl;
i++;
if(i < 3)
GOTOSTMT
}
随机downvoter请解释你的理由 – 2014-09-29 15:02:25
如果你足够疯狂的做,你可以定义你的整个程序作为一个巨大的宏观两者。 – gnasher729 2014-09-29 13:16:19
这个问题怎么不清楚? – NPE 2014-09-29 13:19:29
真正的问题是你为什么要这么做 – 2014-09-29 13:19:29