vscode-cpptools
vscode-cpptools copied to clipboard
Variadic macro not expanded correctly
In the following code:
#define Get2ndVariadicArg(a, b, ...) b
#define Assert(condition, ...) HandleAssert("msg", Get2ndVariadicArg(0, ##__VA_ARGS__, #condition))
#define HandleAssert(msg, format) MyAssert(msg, format)
int main()
{
void * p = nullptr;
auto mytest = Assert(p != nullptr);
}
visual studio code IntelliSense expend the Assert
macro like this:
auto mytest = MyAssert("msg", )
but cl /P /C main.cpp
expend the macro the following
auto mytest = MyAssert("msg", "p != nullptr");
How can I have a consistent behavior with cl
? Is it a bug in IntelliSense?
Hi @stephane-archer . Thanks for reporting this. I'm able to repro. The issue also repro's in VS, which shares the same IntelliSense implementation. I've opened an issue internally against VS to address this.
I take it that this is the same issue I'm seeing here?
@Ma-XX-oN I believe so.
This is tracked internally as 1409182, but there are multiple other VA_ARGS/macro issues that may be duplicates as well.
@stephane-archer @Ma-XX-oN Fixed in 1.13.1: https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.1
@sean-mcmanus you are the best! :D
Glad to hear that this got fixed. Well done!