FLTK logo

[fltk.general] Re: Fl_Sys_Menu's add method throws errors.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Fl_Sys_Menu's add method throws errors. Greg Ercolano Jan 13, 2014  
 
> Hey there. In one of the examples, I changed Fl_Menu to Fl_Sys_Menu to have it work with OS X. Result:
>
> *** Compile menubar-add.cxx...
> menubar-add.cxx:59:29: error: cannot initialize a parameter of type 'int' with an lvalue of type 'const char [3]'
>  menu->add("&File/&Open",  "^o", MyMenuCallback);
>                            ^~~~

Might want to open an STR for this.

Seems Fl_Sys_Menu_Bar.H is not giving access to Fl_Menu_'s version of add()
that accepts a const char* as the second parameter, basically an overload.

Might be some weird compiler phase issue; quoting the possibly relevant comment #3 from:
http://www.gamedev.net/topic/478757-c-inline-and-inheritance/

"""

    The reason the name is hidden is because name lookup terminates as soon as
    a suitable name is found, and overload resolution is done in a separate phase.
    The using directive pulls the other overloads from the base into the derived class
    namespace, so that they will be found in phase one.

"""

I tried a variation of the recommendation suggested in that comment, and it seemed
to solve the issue.. might be the 'right' solution, not sure:

Index: FL/Fl_Sys_Menu_Bar.H
===================================================================
--- FL/Fl_Sys_Menu_Bar.H    (revision 10054)
+++ FL/Fl_Sys_Menu_Bar.H    (working copy)
@@ -45,6 +45,7 @@
   const Fl_Menu_Item *menu() const {return Fl_Menu_::menu();}
   void menu(const Fl_Menu_Item *m);
   int add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0);
using Fl_Menu_::add;
   int insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data=0, int flags=0);
   void remove(int n);
   void replace(int rank, const char *name);

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.