Vscode-cpptools: errorSquiggles 'user-defined literal operator not found' for macro

Created on 27 Sep 2017  路  10Comments  路  Source: microsoft/vscode-cpptools


Operating Sytem:Win7 X86_64
VS Code: V1.17.0-insider
C/C++ extension version: 0.13.0

only if

  • macro has parameters
  • call the macro with "%s"
  • the macro defined with do while
  • the do{ in the same line with define

a.h

#define LOG_ERROR(format, argv...) do {    \
                printf("[%s|%d]"format, __FILE__, __LINE__, ##argv); \
} while (0)
````
a.cpp
```cpp
#include "a.h"
...
LOG_ERROR("%s", "abc");
...
Language Service Visual Studio bug

Most helpful comment

I have noticed this as well, still now. When I use catch2 (c++ testing framework), all of my REQUIRE macros will be underlined with this "error".

All 10 comments

Thanks for reporting this. I also saw it last week while getting a demo ready for CppCon, but forgot to log an issue for it. I was able to work around the issue by adding whitespace between the quoted text and the argument (e.g. "format" in your case)

I have noticed this as well, still now. When I use catch2 (c++ testing framework), all of my REQUIRE macros will be underlined with this "error".

The bug repros with Visual Studio as well. I've reported bug https://developercommunity.visualstudio.com/content/problem/377739/c-intellisense-reports-invalid-user-defined-litera.html .

As a workaround, you could use "[%s|%d]"##format or "[%s|%d]" format as Bob suggested.

You also need a comma before the "...".

When I use catch2 (c++ testing framework), all of my REQUIRE macros will be underlined with this "error".

I am using Catch2 as well and it is driving me crazy. What have you done in the mean time? Disable error squiggles altogether?

image

Hi @pedzed
I reported issue #2786 which relates a little bit more to my specific case with Catch2. Maybe you can try some of the suggestions made in there, however I found them unsuccessful. However, for unrelated reasons, we have since decided to use GoogleTest instead. GoogleTest did not have this problem.

I'm using Catch2, and I'm getting the same problem!

Upvote, it's driving me insane too. Using Catch2!

@shehabattia96 Upvotes to this issue may not be "counted", because the issue is being tracked by https://developercommunity.visualstudio.com/content/problem/377739/c-intellisense-reports-invalid-user-defined-litera.html , but that requies a Microsoft account to upvote.

I've filed a request to enable GitHub users to upvote VS issues without a Microsoft account at https://developercommunity.visualstudio.com/idea/869998/enable-vs-code-users-with-github-accounts-to-upvot.html

@sean-mcmanus Thanks for creating a ticket and for letting me know! HNY!

A potential workaround is to use

#if __INTELLISENSE__
#pragma diag_suppress 2486
#endif
Was this page helpful?
0 / 5 - 0 ratings