I have an issue, which I guess is caused by the Microsoft C/C++ plugin. Intellisense is showing errors at Google Test functions, but there are no actual errors (tests compile and run without any problem).
When I hover over the functions with these red error squiggles, it expands to the functionality, F12 (go to definition) works as well.
How do I get rid of these intellisense "errors"?
I have tried searching for the error messages, for "intellisense Gtest VSCode" and similar, but no luck in finding any useful solution. My guess is that I missed something, but what?
Have also tried playing around with c_cpp_properties.json (tried to include the exact path to gtest, to force include the actual gtest.h file, etc) but no luck there either.
It is pretty simple, basically:
"includePath": [
"${workspaceFolder}/**"
],
typedef struct {
unsigned short a;
} myStruct;
myStruct s[5];
unsigned short someFunction(void)
{
// Do stuff
return s[somePosition].a;
}
#include "gtest/gtest.h"
extern "C" {
#include "somefile.h"
extern myStruct s[];
}
TEST(someTest, firstTest)
{
EXPECT_EQ(s[somePosition].a, someFunction());
}
INSTANTIATE_TEST_CASE_P(someFunction, secondTest,
testing::Values(
some_test{ "hello", 0 },
some_test{ "bye", 1 }
));
firstTest, error at EXPECT_EQ:
expression must have bool type (or be convertible to bool)C/C++(711)
secondTest, error at INSTANTIATE_TEST_CASE_P:
namespace "std" has no member "string"C/C++(135)
Solved it by editing c_cpp_properties.json:
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/Tests/packages/Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1/build/native/include/**"
],