On 01/08/12 04:48, Albrecht Schlosser wrote: > Users are encouraged to do something like this in their main program > or wherever they have potential ABI differences: > > if (fl_abi_version() != FL_ABI_VERSION) > fl_abort ("FLTK ABI version mismatch: %d != %d", > fl_abi_version(), FL_ABI_VERSION); > > We could also add this to check the version and abort the program > if it doesn't match: > > void fl_check_abi_version(int version) { > if (fl_abi_version() != version) > Fl::fatal ("FLTK ABI version mismatch: %d != %d", > fl_abi_version(), version); > return; > }
Along that subject, perhaps if we use an inline function or macro, the syntax could be easier for the user, e.g. int main() { fl_check_version(); // check for FLTK version sync issues .. } ..where the code might be: /// Return an error message if the fltk build version doesn't match /// the app's compile time version#, or NULL if no issues were found. /// /// Optional \p warn flag indicates whether Fl::warn() is used to show /// any errors encountered. /// inline const char *fl_check_version(int warn=1) { static char err[80]; if ( FL_VERSION != fl_get_version() ) { sprintf(err, "fltk version mismatch: lib=%lf, compile=%lf", fl_get_version(), FL_VERSION); if ( warn ) Fl::warn(err); return(err); } if ( FL_ABI_VERSION != fl_get_abi_version() ) { sprintf(err, "fltk abi version mismatch: lib=%lf (%s), compile=%lf(%s)", fl_get_version(), (fl_get_abi_version()?"on":"off"), FL_VERSION, FL_ABI_FEATURES?"on":"off"); if ( warn ) Fl::warn(err); return(err); } return(0); } If an inline doesn't work for this, a macro could wrap it to keep the usage just as simple. And I suppose if we wanted the check to be automagic, we could perhaps make Fl::run() an inline to do the check, something most apps call. _______________________________________________ fltk-dev mailing list fltk-dev@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-dev