Skip to content

Support for Initialization Outside of Main #433

@mikejr83

Description

@mikejr83

I'm trying to get this library set-up so that I can initialize a rather complex menu structure in a separate file. How can I do this? It doesn't seem possible that I can return nav:

MenuConfig.cpp

Menu::navRoot CreateMenu()
{
  // create menu structure
  NAVROOT(nav, mainMenu, MAX_DEPTH, in, out);

  return nav;
}

main.cpp

Menu::navRoot nav = CreateMenu();

void setup(void) 
{
  // set up Serial, etc.
}

void loop(void)
{
  nav.poll();
}

I've tried several ways, like passing references, etc. The program seems to crash in the loop.

Is there a way to do this or do am I forced to have a gigantic main.cpp file?!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions