cspec icon indicating copy to clipboard operation
cspec copied to clipboard

Error Squiggle when copy-pasting example code into Visual Studio Code

Open f-and opened this issue 1 year ago • 3 comments

Error

Upon clean install of cspec, following the explanation in the README.md file, and including the required header files for the example file copied from the previous file, Visual Studio Code (with C/C++ extensions installed) detects the error:

argument of type "void" is incompatible with parameter of type "Runnable"C/C++(167)

Though this error is only aesthetic, as the file compiles correctly and the tests run as expected.

Steps to reproduce it

  • Clean install of cspec
  • Copy full example off README.md into a .c file.
  • Check Intellisense's error

Things attempted to fix the error:

  • Copy the replaced text (__describe("Hello world", ({ void __$__()) into the file.
  • Change Intellisense's version of the compiler
  • Switched from GCC to CLang and back
  • Tested in different computers

Attached a screenshot of the error in question, the second error comes from not detecting the first one as a correct structure, so it doesn't matter for the initial issue.

2023-04-05-19:56:45-screenshot

f-and avatar Apr 05 '23 23:04 f-and

Same error here in macosx 14 with no workaround. Any ideas ?

Juancete avatar Mar 26 '24 22:03 Juancete

This library relies heavily on nested functions, which is a gcc specific feature, so:

  1. VSCode IntelliSense is not smart enough to recognize them (see https://github.com/microsoft/vscode-cpptools/issues/1035). I recommend disabling IntelliSense and configuring a build task to get error squiggles directly from gcc compiler:
// settings.json
{
  "C_Cpp.errorSquiggles": "disabled"
} 
// tasks.json
{ 
  "version": "2.0.0", 
  "tasks": [ 
    { 
      "label": "build",
      "command": "make all", // or the command you use to build the project
      "type": "shell",
      "group": {
        "kind": "build", 
        "isDefault": true
      }, 
      "problemMatcher": ["$gcc"]
    }
  ]
}
  1. In MacOS, gcc is just an alias for clang compiler, which doesn't support nested functions. As far as I know^1, you can install GCC compiler using Homebrew, but I don't have a MacOS to confirm that 😅

RaniAgus avatar Apr 08 '24 13:04 RaniAgus

In MacOS, gcc is just an alias for clang compiler, which doesn't support nested functions. As far as I know1, you can install GCC compiler using Homebrew, but I don't have a MacOS to confirm that

Yes, you can. But you have to include manually /usr/local/lib and /usr/local/include paths to work with homebrew's gcc. Thanks @RaniAgus

Juancete avatar Apr 09 '24 18:04 Juancete