Skip to content

Automatic function prototype generation does not work inside namespaces #5984

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

Closed
nickgammon opened this issue Feb 13, 2017 · 2 comments
Closed
Labels
Component: Compilation Related to compilation of Arduino sketches Type: Bug Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature

Comments

@nickgammon
Copy link

nickgammon commented Feb 13, 2017

In the example code below I am placing some functions into a namespace to avoid clashes. (This is in answer to a question about combining two sketches). However the automated function-prototype generation seems to be suppressed inside a namespace.

namespace foo 
{
//  void bar ();
  
  void fubar ()
     {
     bar (); 
     }  // end of fubar
     
  void bar ()
    {
    }  // end of bar
}  // end of namespace foo 

void setup()
{
  foo::fubar ();
}  // end of setup

void loop()
{
}  // end of loop

If you uncomment the manual function prototype near the top the code compiles OK. As written however I get the error:

/home/nick/Pictures/Blink tutorial/Example/Example.ino: In function 'void foo::fubar()':
Example:7: error: 'bar' was not declared in this scope
      bar (); 
           ^
exit status 1
'bar' was not declared in this scope

This is with IDE 1.8.1.

@facchinm
Copy link
Member

Hi Nick, prototypes are not autogenerated for classes and namespaces (see https://github.com/arduino/arduino-builder/blob/a4ede088e7f5fa67fd7c2f12b94e3124126bae00/src/arduino.cc/builder/ctags/ctags_parser.go#L206) . The reason is that it's really difficult to find the correct insertion point for these prototypes, so we avoid creating them (silently). Maybe this proposal could help? Would you mind continuing the discussion there?

@nickgammon
Copy link
Author

OK, I'll close this issue as it seems to be by design.

@per1234 per1234 added Type: Bug Component: Compilation Related to compilation of Arduino sketches Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature labels Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Compilation Related to compilation of Arduino sketches Type: Bug Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature
Projects
None yet
Development

No branches or pull requests

3 participants