mumuki / cspec

Small BDD framework for C/C++
GNU General Public License v3.0
106 stars 18 forks source link

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

Open f-and opened 1 year ago

f-and commented 1 year ago

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

Things attempted to fix the error:

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

Juancete commented 7 months ago

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

RaniAgus commented 7 months ago

This library relies heavily on constructors, and other gcc specific features, 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 😅
Juancete commented 7 months ago

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