Dlaczego nie skomentowano wiersza komentarza w poniższym programie?Przekazywanie listy inicjalizacyjnej do makra
#include <iostream>
#include <vector>
using namespace std;
#define F1(a) 1
int F2(vector<int>) { return 2; }
int main() {
vector<int> v;
v = vector<int>{1,2,3};
cout << F1(v) << endl;
//The following line doesn't compile. The error is:
//error: macro "F" passed 3 arguments, but takes just 1
//cout << F1(vector<int>{1,2,3}) << endl; // <- error!
cout << F1(vector<int>({1,2,3})) << endl;
cout << F1((vector<int>{1,2,3})) << endl;
cout << F2(v) << endl;
//The following line compiles fine
cout << F2(vector<int>{1,2,3}) << endl;
cout << F2(vector<int>({1,2,3})) << endl;
cout << F2((vector<int>{1,2,3})) << endl;
return 0;
}
Sieć [ Dokumentacja online GCC] (https: //gcc.gnu.o rg/onlinedocs/cpp/Macro-Arguments.html) ma ładny przykład i wyjaśnienie. –