"Function definition for '' not found" message appears when defining a function with a macro
Environment
- OS and Version: Ventura 13.6
- VS Code Version: 1.82.2
- C/C++ Extension Version: v1.17.5
Bug Summary and Steps to Reproduce
Bug Summary:
If I define a function with a macro vscode can't find the definition and it reports an error
Steps to reproduce: Type this code
#define define_foo(Type) \
void foo(const string &key, Type value) {}
define_foo(bool);
define_foo(char);
Expected behavior:
I don't get this error message
Other Extensions
No response
Additional context
No response
That error appears to be from another extension. Errors from our extension look like C/C++(<error code>). Your message shows no error code and doesn't match any error message we return.
@sean-mcmanus I only have the c++ extension installed
and if I disable it the message goes away, also this won't appear as an error. just three dots at the beginning of the string like in the screenshot
I reproduce the issue. This is a bug.
Ah, okay, I see now -- it's not an IntelliSense error (red squiggle) it's a CDD error message (from the "...").
The issue is inherited from the shared code from Visual Studio:
I've encountered this issue with class member functions. If you wrap the class part in a macro, it will think almost every function definition in the class doesn't exist, even if it does.
Example
Foo.hpp
#pragma once
#define CLASS(T) class T
CLASS(Foo)
{
public:
void Bar();
void Baz();
void Test();
};
Foo.cpp
#include "Foo.hpp"
void Foo::Bar()
{
}
void Foo::Baz()
{
}
void Foo::Test()
{
}
Result
Oddly, it appears the first function in the class (Bar) doesn't have the issue, but the ones after it do (Baz and Test).
I'm observing the same, also very visible in Zephyr and it's macros for callback functions:
This problem has been tortured me in the last two weeks, Any update?
Could be possible to just turn off this?
Ah, okay, I see now -- it's not an IntelliSense error (red squiggle) it's a CDD error message (from the "...").
What is a "CDD error" and how do I turn it off?
Sorry for not following up on this issue -- it is actually not a bug, but "by design" -- the feature requires that you create a cpp.hint file with the macro, e.g. #define define_foo(Type). Then the error will disappear.
See https://developercommunity.visualstudio.com/t/C-Create-Definition-suggestions-dont/10826411 .
Also, there is no setting to turn it off, but someone could open a request for us to add such a setting (it might also be possible to submit a PR to enable disabling it from the open source TypeScript).
Sorry for not following up on this issue -- it is actually not a bug, but "by design" -- the feature requires that you create a cpp.hint file with the macro, e.g.
#define define_foo(Type). Then the error will disappear.See https://developercommunity.visualstudio.com/t/C-Create-Definition-suggestions-dont/10826411 .
Also, there is no setting to turn it off, but someone could open a request for us to add such a setting (it might also be possible to submit a PR to enable disabling it from the open source TypeScript).
Creating a cpp.hint file, no matter where, did not solve the problem for me. Either it is not being picked up correctly by the extension, or there's something else going wrong:
I placed a cpp.hint into the workspace root but also in some subfolders:
@lmapii Your screenshot shows a different error identifier __FILE_NAME__ is undefined. It's already being tracked by https://github.com/microsoft/vscode-cpptools/issues/11164 .