0

Hi the Stackoverflow community,

I'm trying to compile the following code in the Visual Studio C++ 2022 compiler. Here's my code,

 #include <iostream>
using namespace std;
 
#define dbg(x...) 
 
int main() {
 
    return 0;
}

As you can see the code above can be compiled with gcc 8.3. However, if you use Visual Studio 2022 C++ compiler you will get the following error:

main.cpp(?): error C2010: '.': unexpected in macro parameter list

My question is the following. How can we find an equivalent solution to the problem such that I can compile under VS2022 C++? Thank you.

Zack Ni
  • 179
  • 3
  • 8
  • 2
    https://learn.microsoft.com/en-us/cpp/preprocessor/variadic-macros?view=msvc-170 seems like thats not allowed – pm100 May 29 '22 at 17:48
  • 1
    As you can see this is not permitted in Standard C++ - live - https://godbolt.org/z/8YoGrczxh "_warning: named variadic macros are a GNU extension [-Wvariadic-macros] "_ – Richard Critten May 29 '22 at 17:51
  • 1
    The syntax described in [Cppreference](https://en.cppreference.com/w/cpp/preprocessor/replace) requires the ellipsis to be placed either following the parameters list and a comma, or just by itself (i.e., without any other parameters). – heap underrun May 29 '22 at 18:17

0 Answers0