Skip to content

Automatic function prototype generation does not work inside namespaces #5984

Closed
@nickgammon

Description

@nickgammon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CompilationRelated to compilation of Arduino sketchesType: BugType: WontfixArduino has decided that it will not resolve the reported issue or implement the requested feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions