Passing an initialization list to a macro

前端 未结 3 2293
时光取名叫无心
时光取名叫无心 2021-02-18 18:07

Why doesn\'t the commented out line in the following program compile?

#include 
#include 
using namespace std;

#define F1(a) 1

in         


        
3条回答
  •  日久生厌
    2021-02-18 19:14

    Another workaround is to transform your macro into a variadic macro

    #define F1(...) 1
    

    Or, in a more general case:

    #define M(a) a
    

    into

    #define M(...) __VA_ARGS__
    

提交回复
热议问题