comp.lang.ada
 help / color / mirror / Atom feed
From: Ron Wills <ron.rwsoft@gmail.com>
Subject: Linking Ada to C++ Overloaded Functions and Methods
Date: Sat, 7 Apr 2018 11:35:00 -0700 (PDT)
Date: 2018-04-07T11:35:00-07:00	[thread overview]
Message-ID: <c157fac7-28a4-4233-a825-f02ccd3adcd8@googlegroups.com> (raw)

I know that both Ada and C++ can overload functions and methods. The problem I'm having is when I'm trying to link Ada to overload C++ functions. I know I could use different Ada names, but if it's possible to keep the same names in Ada it would save a lot of re-coding.

An example is from the FLTK library. The "draw_box" method from the Fl_Widget class is overloaded and I get the following from g++ -fdump-ada-spec.

procedure draw_box (this : access constant Fl_Widget'Class);
pragma Import (CPP, draw_box, "_ZNK9Fl_Widget8draw_boxEv");

procedure draw_box
  (this : access constant Fl_Widget'Class;
   t : Fl_Enumerations_H.Fl_Boxtype;
   c : Fl_Enumerations_H.Fl_Color);  -- /usr/include/Fl/Fl_Widget.H:181
pragma Import (CPP, draw_box, "_ZNK9Fl_Widget8draw_boxE10Fl_Boxtypej");

The C++ name mangling works to uniquely identify the C++ methods, but the compiler is choking on the Ada names as already being declared.

fl_fl_widget_h.ads:171:07: entity "draw_box" was previously imported
fl_fl_widget_h.ads:171:07: (pragma "Import" applies to all previous entities)
fl_fl_widget_h.ads:171:07: import not allowed for "draw_box" declared at line 164
fl_fl_widget_h.ads:181:07: entity "draw_box" was previously imported
fl_fl_widget_h.ads:181:07: (pragma "Import" applies to all previous entities)
fl_fl_widget_h.ads:181:07: import not allowed for "draw_box" declared at line 167

Is there a way to use overloaded Ada names with C++ or do I need to find a unique Ada name for every C++ overload method?


             reply	other threads:[~2018-04-07 18:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-07 18:35 Ron Wills [this message]
2018-04-07 19:01 ` Linking Ada to C++ Overloaded Functions and Methods Dan'l Miller
2018-04-07 19:05 ` Niklas Holsti
2018-04-07 20:07   ` Ron Wills
2018-04-07 20:25     ` Jere
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox