2

For example, if this is in a C file:

#include <stdio.h>

int main() {
    puts(R"(PREPROCESSOR DIRECTIVES
The following are the preprocessor directives in C:
#define  - Replaces parts of the code. Non-function macros are usually named in UPPERCASE.
#include - Inserts a header file into the current file.
#ifdef   - Runs more preprocessor directives below until reaching an #endif, if something is defined.)");
}

it probably has bad practices I just made this quickly

It runs fine, but vscode bombards me with 7 useless errors. Sure, vscode lets it compile, but it's just annoying to see your errors tab full of fake errors. How can I fix it?

  • identifier "R" is undefined
  • missing closing quote
  • expected an identifier (2)
  • expected a file name
  • the #endif for this directive is missing
  • expected a ";"

My question is "how can I make vscode not throw errors about raw strings" not "how can I make C have raw strings" if it wasn't clear already

Bfyuvf
  • 139
  • 9
  • You should probably tell your build environment. I don't think this is standard C, but an extension. Related: https://stackoverflow.com/questions/24850244/does-c-support-raw-string-literals – hyde Nov 16 '22 at 05:09
  • Also it would probably be important to know which related VSCode extensions you are using, or just that you have not installed any extra extensions, it's clean out-of-the-box install. – hyde Nov 16 '22 at 05:12
  • @hyde vscode with mingw, with the C/C++ extension. I wasn't asking about if its valid, just asking how to disable it, and also that question you linked is also linked in my question – Bfyuvf Nov 17 '22 at 02:14
  • This isn't something you disable so much as you extend the parser to understand it. The code parser is completely confused as to what this even is. It can't ignore it, it can't even comprehend it. – tadman Nov 20 '22 at 05:38

1 Answers1

1

Raw strings are not standard C. I see they are accepted by gcc so that seems to be a gcc extension. What is happening is that you compile with gcc, but realtime error highlight system (intellisense, squiggles, whatever it is called) uses either a clang based solution or Visual Studio one.

bolov
  • 72,283
  • 15
  • 145
  • 224