Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function definition can't be found when the implementation is done in a macro #13141

Closed
dortamiguel opened this issue Jan 11, 2025 · 3 comments
Closed

Comments

@dortamiguel
Copy link

dortamiguel commented Jan 11, 2025

Environment

  • OS and Version: macOS Sonoma 14.5
  • VS Code Version: 1.96.2
  • C/C++ Extension Version: 1.22.11

Bug Summary and Steps to Reproduce

I have the following code that defines the implementation of a function using a macro

struct Foo {
    void hello();
};

#define FOO_HELLO() \
    void Foo::hello() {}

FOO_HELLO();

But I'm getting the following warnings:

Image

Image

Since hello is actually defined I would expect not seeing this warning

Configuration and Logs

  "C_Cpp.default.cStandard": "c11",
  "C_Cpp.default.cppStandard": "c++20",
  "C_Cpp.default.defines": ["__DEVELOPMENT__", "__PRODUCTION__", "__TEST__"],
  "C_Cpp.default.forcedInclude": ["include/base.hpp", "src/console.hpp"],
  "C_Cpp.default.includePath": ["lib/macos/include", "include", "."],
  "C_Cpp.suggestSnippets": false,
  "C_Cpp.dimInactiveRegions": false,
  "C_Cpp.codeAnalysis.updateDelay": 0,
  "C_Cpp.intelliSenseUpdateDelay": 500,
@sean-mcmanus
Copy link
Contributor

@dortamiguel I've reported a bug on our shared implementation with VS at https://developercommunity.visualstudio.com/t/C-Create-Definition-suggestions-dont/10826411

@sean-mcmanus
Copy link
Contributor

@dortamiguel It turns out this is "by design" and you need to add the macros to a cpp.hint file, such as

#define FOO_HELLO() void Foo::hello() {}

and then do a Reload Window.

@sean-mcmanus sean-mcmanus removed this from the Tracking milestone Jan 13, 2025
@dortamiguel
Copy link
Author

@sean-mcmanus could be possible to just turn off the warning then?

I'm using macros to generate declarations so I don't have to type them, if I have to type the definition in a hint file then there is no point of using the macro at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants