From: Jean-Marc Lasgouttes Date: Tue, 19 Oct 1999 15:06:30 +0000 (+0000) Subject: A bunch of obvious changes to please strict ansi compilers. Not finished. X-Git-Tag: 1.6.10~22601 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c35b288b74ac9b1450a81c1520292ab95735bb0f;p=features.git A bunch of obvious changes to please strict ansi compilers. Not finished. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@210 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 607dd84585..b80bba59d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +1999-10-19 Jean-Marc Lasgouttes + + * src/mathed/math_symbols.C, src/support/lstrings.C, + src/support/lyxstring.C: add `using' directive to specify what + we need in . I do not think that we need to + conditionalize this, but any thought is appreciated. + + * many files: change all callback functions to "C" linkage + functions to please strict C++ compilers like DEC cxx 6.1 in mode + strict_ansi. Those who were static are now global. + The case of callbacks which are static class members is + trickier, since we have to make C wrappers around them (see + InsetError, InsetInfo and InsetUrl). The same holds for friends. I + did not finish this yet, since it defeats the purpose of + encapsulation, and I am not sure what the best route is. + 1999-10-19 Juergen Vigna * src/support/lyxstring.C (lyxstring): we permit to have a null diff --git a/src/LyXAction.C b/src/LyXAction.C index 55247ae1c0..15c535bd6b 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -717,7 +717,7 @@ char const *LyXAction::helpText(kb_action action) const // Function to compare items from the attrib table. -int actioncomp(const void *a, const void *b) +extern "C" int actioncomp(const void *a, const void *b) { int const *ia=(int const*)a, *ib=(int const*)b; return (*ia)-(*ib); diff --git a/src/bmtable.C b/src/bmtable.C index a479397a48..bf0b0f9842 100644 --- a/src/bmtable.C +++ b/src/bmtable.C @@ -32,8 +32,8 @@ typedef struct { } BMTABLE_SPEC; -static int handle_bitmaptable(FL_OBJECT *ob, int event, FL_Coord mx, - FL_Coord my, int key, void *xev); +extern "C" int handle_bitmaptable(FL_OBJECT *ob, int event, FL_Coord mx, + FL_Coord my, int key, void *xev); FL_OBJECT *fl_create_bmtable(int type, FL_Coord x, FL_Coord y, @@ -165,8 +165,8 @@ static void draw_bitmaptable(FL_OBJECT *ob) } -static int handle_bitmaptable(FL_OBJECT *ob, int event, FL_Coord mx, - FL_Coord my, int key, void */*xev*/) +extern "C" int handle_bitmaptable(FL_OBJECT *ob, int event, FL_Coord mx, + FL_Coord my, int key, void */*xev*/) { int i, j; BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec; diff --git a/src/bullet_forms.h b/src/bullet_forms.h index 5c9293157d..4ff02108fb 100644 --- a/src/bullet_forms.h +++ b/src/bullet_forms.h @@ -4,14 +4,14 @@ #define FD_form_bullet_h_ /** Callbacks, globals and object handlers **/ -extern void ChoiceBulletSizeCB(FL_OBJECT *, long); -extern void BulletOKCB(FL_OBJECT *, long); -extern void BulletApplyCB(FL_OBJECT *, long); -extern void BulletCancelCB(FL_OBJECT *, long); -extern void InputBulletLaTeXCB(FL_OBJECT *, long); -extern void BulletDepthCB(FL_OBJECT *, long); -extern void BulletPanelCB(FL_OBJECT *, long); -extern void BulletBMTableCB(FL_OBJECT *, long); +extern "C" void ChoiceBulletSizeCB(FL_OBJECT *, long); +extern "C" void BulletOKCB(FL_OBJECT *, long); +extern "C" void BulletApplyCB(FL_OBJECT *, long); +extern "C" void BulletCancelCB(FL_OBJECT *, long); +extern "C" void InputBulletLaTeXCB(FL_OBJECT *, long); +extern "C" void BulletDepthCB(FL_OBJECT *, long); +extern "C" void BulletPanelCB(FL_OBJECT *, long); +extern "C" void BulletBMTableCB(FL_OBJECT *, long); /**** Additional routines ****/ diff --git a/src/credits_form.h b/src/credits_form.h index 58ac09947d..5cd8777eb4 100644 --- a/src/credits_form.h +++ b/src/credits_form.h @@ -4,9 +4,9 @@ #define FD_form_credits_h_ /** Callbacks, globals and object handlers **/ -extern void CreditsOKCB(FL_OBJECT *, long); +extern "C" void CreditsOKCB(FL_OBJECT *, long); -extern void CopyrightOKCB(FL_OBJECT *, long); +extern "C" void CopyrightOKCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/form1.h b/src/form1.h index cf2ab3fe16..511aa55ebb 100644 --- a/src/form1.h +++ b/src/form1.h @@ -5,18 +5,18 @@ /** Callbacks, globals and object handlers **/ -extern void GraphicsCB(FL_OBJECT *, long); +extern "C" void GraphicsCB(FL_OBJECT *, long); -extern void TableOKCB(FL_OBJECT *, long); -extern void TableApplyCB(FL_OBJECT *, long); -extern void TableCancelCB(FL_OBJECT *, long); +extern "C" void TableOKCB(FL_OBJECT *, long); +extern "C" void TableApplyCB(FL_OBJECT *, long); +extern "C" void TableCancelCB(FL_OBJECT *, long); -extern void SearchForwardCB(FL_OBJECT *, long); -extern void SearchBackwardCB(FL_OBJECT *, long); -extern void SearchReplaceCB(FL_OBJECT *, long); -extern void SearchCancelCB(FL_OBJECT *, long); -extern void SearchReplaceAllCB(FL_OBJECT *, long); +extern "C" void SearchForwardCB(FL_OBJECT *, long); +extern "C" void SearchBackwardCB(FL_OBJECT *, long); +extern "C" void SearchReplaceCB(FL_OBJECT *, long); +extern "C" void SearchCancelCB(FL_OBJECT *, long); +extern "C" void SearchReplaceAllCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/include_form.h b/src/include_form.h index eb333f4b3f..a4c99ea019 100644 --- a/src/include_form.h +++ b/src/include_form.h @@ -4,7 +4,7 @@ /**** Callback routines ****/ -extern void include_cb(FL_OBJECT *, long); +extern "C" void include_cb(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 82f72a2cb1..c85889ae60 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -60,8 +60,8 @@ extern BufferView *current_view; static volatile bool alarmed; extern FL_OBJECT *figinset_canvas; -inline -void waitalarm(int) +//inline +extern "C" void waitalarm(int) { alarmed = true; } @@ -136,7 +136,7 @@ void addpidwait(int pid) } -int GhostscriptMsg(FL_OBJECT *, Window, int, int, +extern "C" int GhostscriptMsg(FL_OBJECT *, Window, int, int, XEvent *ev, void *) { int i; diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index ab5ed93f8c..e66147d3a9 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -27,12 +27,11 @@ static Combox *bibcombox = 0; extern void UpdateInset(Inset* inset, bool mark_dirty = true); void BibitemUpdate(Combox *); -void bibitem_cb(FL_OBJECT *, long); FD_citation_form * create_form_citation_form(void); FD_bibitem_form * create_form_bibitem_form(void); -void bibitem_cb(FL_OBJECT *, long data) +extern "C" void bibitem_cb(FL_OBJECT *, long data) { switch (data) { // case 0: fl_hide_form(citation_form->citation_form); diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index 869d349757..09c1cd4dd1 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -150,6 +150,13 @@ void InsetError::CloseErrorCB(FL_OBJECT *, long data) } } +// A C wrapper +extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT *, long data) +{ + InsetError::CloseErrorCB(0,data); +} + + void InsetError::Edit(int, int) { if (!form) { @@ -159,7 +166,7 @@ void InsetError::Edit(int, int) fl_set_object_color(strobj,FL_MCOL,FL_MCOL); fl_set_object_gravity(strobj, FL_NorthWest, FL_SouthEast); obj = fl_add_button(FL_RETURN_BUTTON,140,200,120,30,_("Close")); - fl_set_object_callback(obj, CloseErrorCB, (long)this); + fl_set_object_callback(obj, C_InsetError_CloseErrorCB, (long)this); fl_set_object_gravity(obj, FL_South, FL_South); fl_set_object_resize(obj, FL_RESIZE_NONE); fl_end_form(); diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index 59b9cfcb58..cdc03f41dc 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -67,6 +67,8 @@ public: Inset::Code LyxCode() const { return Inset::NO_CODE; } /// We don't want "begin" and "end inset" in lyx-file bool DirectWrite() const { return true; }; + /// + static void CloseErrorCB(FL_OBJECT *, long data); private: /// string contents; @@ -74,7 +76,5 @@ private: FL_FORM *form; /// FL_OBJECT *strobj; - /// - static void CloseErrorCB(FL_OBJECT *, long data); }; #endif diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index f10b1f0a48..554ae2a3cb 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -88,7 +88,7 @@ FD_include *create_form_include(void) FD_include *form = 0; -void include_cb(FL_OBJECT *, long arg) +extern "C" void include_cb(FL_OBJECT *, long arg) { InsetInclude *inset = (InsetInclude*)form->vdata; diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index 018d9370f6..035c3dd511 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -20,8 +20,7 @@ extern void UpdateInset(Inset* inset, bool mark_dirty = true); FD_index_form *index_form = 0; -static -void index_cb(FL_OBJECT *, long data) +extern "C" void index_cb(FL_OBJECT *, long data) { InsetIndex *inset = (InsetIndex*)index_form->vdata; diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index 9174dd00b2..00665337ae 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -170,6 +170,11 @@ void InsetInfo::CloseInfoCB(FL_OBJECT *, long data) } } +// This is just a wrapper. +extern "C" void C_InsetInfo_CloseInfoCB(FL_OBJECT *, long data) +{ + InsetInfo::CloseInfoCB(0, data); +} void InsetInfo::Edit(int, int) { @@ -186,7 +191,7 @@ void InsetInfo::Edit(int, int) obj = fl_add_button(FL_NORMAL_BUTTON,130,140,120,30,idex(_("Close|#C^["))); fl_set_object_resize(obj, FL_RESIZE_NONE); fl_set_object_gravity(obj, SouthWestGravity, SouthEastGravity); - fl_set_object_callback(obj, CloseInfoCB, (long)this); + fl_set_object_callback(obj, C_InsetInfo_CloseInfoCB, (long)this); fl_set_object_shortcut(obj, scex(_("Close|#C^[")), (long)this); fl_end_form(); fl_set_form_atclose(form, CancelCloseBoxCB, 0); diff --git a/src/insets/insetinfo.h b/src/insets/insetinfo.h index 67eb0499eb..edd3e9fa1e 100644 --- a/src/insets/insetinfo.h +++ b/src/insets/insetinfo.h @@ -65,6 +65,8 @@ public: Inset::Code LyxCode() const; /// Inset* Clone(); + /// + static void CloseInfoCB(FL_OBJECT *, long data); private: /// string contents; @@ -72,8 +74,6 @@ private: FL_FORM *form; /// FL_OBJECT *strobj; - /// - static void CloseInfoCB(FL_OBJECT *, long data); }; #endif diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 5124c15455..b7efb774c0 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -99,6 +99,10 @@ void InsetUrl::CloseUrlCB(FL_OBJECT *ob, long) } } +extern "C" void C_InsetUrl_CloseUrlCB(FL_OBJECT *ob, long) +{ + InsetUrl::CloseUrlCB(0,0); +} void InsetUrl::Edit(int, int) { @@ -116,7 +120,7 @@ void InsetUrl::Edit(int, int) obj = fl_add_button(FL_RETURN_BUTTON,360,130,100,30,idex(_("Close|#C^[^M"))); fl_set_button_shortcut(obj,scex(_("Close|#C^[^M")),1); obj->u_vdata = this; - fl_set_object_callback(obj,CloseUrlCB,0); + fl_set_object_callback(obj,C_InsetUrl_CloseUrlCB,0); radio_html = obj = fl_add_checkbutton(FL_PUSH_BUTTON,50,130,240,30,idex(_("HTML type|#H"))); fl_set_button_shortcut(obj,scex(_("HTML type|#H")),1); fl_set_object_lsize(obj,FL_NORMAL_SIZE); diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 3e6c3cb06e..d54768be87 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -74,6 +74,8 @@ public: int Linuxdoc(string &file); /// int DocBook(string &file); + /// + static void CloseUrlCB(FL_OBJECT *, long data); private: /// Url_Flags flag; @@ -85,8 +87,6 @@ private: FL_OBJECT *name_name; /// FL_OBJECT *radio_html; - /// - static void CloseUrlCB(FL_OBJECT *, long data); }; #endif diff --git a/src/latexoptions.h b/src/latexoptions.h index c325c9ebd7..3a4161688b 100644 --- a/src/latexoptions.h +++ b/src/latexoptions.h @@ -4,12 +4,12 @@ #define FD_LaTeXOptions_h_ /** Callbacks, globals and object handlers **/ -extern void LaTeXOptionsOK(FL_OBJECT *, long); -extern void LaTeXOptionsApply(FL_OBJECT *, long); -extern void LaTeXOptionsCancel(FL_OBJECT *, long); +extern "C" void LaTeXOptionsOK(FL_OBJECT *, long); +extern "C" void LaTeXOptionsApply(FL_OBJECT *, long); +extern "C" void LaTeXOptionsCancel(FL_OBJECT *, long); -extern void LatexLogClose(FL_OBJECT *, long); -extern void LatexLogUpdate(FL_OBJECT *, long); +extern "C" void LatexLogClose(FL_OBJECT *, long); +extern "C" void LatexLogUpdate(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/layout_forms.h b/src/layout_forms.h index 901d7c63cb..5446b986ee 100644 --- a/src/layout_forms.h +++ b/src/layout_forms.h @@ -4,47 +4,47 @@ #define FD_form_document_h_ /** Callbacks, globals and object handlers **/ -extern void ChoiceClassCB(FL_OBJECT *, long); -extern void DocumentCancelCB(FL_OBJECT *, long); -extern void DocumentApplyCB(FL_OBJECT *, long); -extern void DocumentOKCB(FL_OBJECT *, long); -extern void DocumentDefskipCB(FL_OBJECT *, long); -extern void DocumentSpacingCB(FL_OBJECT *, long); -extern void DocumentBulletsCB(FL_OBJECT *, long); +extern "C" void ChoiceClassCB(FL_OBJECT *, long); +extern "C" void DocumentCancelCB(FL_OBJECT *, long); +extern "C" void DocumentApplyCB(FL_OBJECT *, long); +extern "C" void DocumentOKCB(FL_OBJECT *, long); +extern "C" void DocumentDefskipCB(FL_OBJECT *, long); +extern "C" void DocumentSpacingCB(FL_OBJECT *, long); +extern "C" void DocumentBulletsCB(FL_OBJECT *, long); -extern void CharacterApplyCB(FL_OBJECT *, long); -extern void CharacterCloseCB(FL_OBJECT *, long); +extern "C" void CharacterApplyCB(FL_OBJECT *, long); +extern "C" void CharacterCloseCB(FL_OBJECT *, long); -extern void ParagraphOKCB(FL_OBJECT *, long); -extern void ParagraphApplyCB(FL_OBJECT *, long); -extern void ParagraphCancelCB(FL_OBJECT *, long); -extern void ParagraphVSpaceCB(FL_OBJECT *, long); -extern void ParagraphExtraOpen(FL_OBJECT *, long); +extern "C" void ParagraphOKCB(FL_OBJECT *, long); +extern "C" void ParagraphApplyCB(FL_OBJECT *, long); +extern "C" void ParagraphCancelCB(FL_OBJECT *, long); +extern "C" void ParagraphVSpaceCB(FL_OBJECT *, long); +extern "C" void ParagraphExtraOpen(FL_OBJECT *, long); -extern void PreambleOKCB(FL_OBJECT *, long); -extern void PreambleApplyCB(FL_OBJECT *, long); -extern void PreambleCancelCB(FL_OBJECT *, long); +extern "C" void PreambleOKCB(FL_OBJECT *, long); +extern "C" void PreambleApplyCB(FL_OBJECT *, long); +extern "C" void PreambleCancelCB(FL_OBJECT *, long); -extern void QuotesOKCB(FL_OBJECT *, long); -extern void QuotesApplyCB(FL_OBJECT *, long); -extern void QuotesCancelCB(FL_OBJECT *, long); +extern "C" void QuotesOKCB(FL_OBJECT *, long); +extern "C" void QuotesApplyCB(FL_OBJECT *, long); +extern "C" void QuotesCancelCB(FL_OBJECT *, long); -extern void PaperMarginsCB(FL_OBJECT *, long); -extern void PaperCancelCB(FL_OBJECT *, long); -extern void PaperApplyCB(FL_OBJECT *, long); -extern void PaperOKCB(FL_OBJECT *, long); +extern "C" void PaperMarginsCB(FL_OBJECT *, long); +extern "C" void PaperCancelCB(FL_OBJECT *, long); +extern "C" void PaperApplyCB(FL_OBJECT *, long); +extern "C" void PaperOKCB(FL_OBJECT *, long); -extern void TableOptCloseCB(FL_OBJECT *, long); -extern void TableOptionsCB(FL_OBJECT *, long); -extern void SetPWidthCB(FL_OBJECT *, long); +extern "C" void TableOptCloseCB(FL_OBJECT *, long); +extern "C" void TableOptionsCB(FL_OBJECT *, long); +extern "C" void SetPWidthCB(FL_OBJECT *, long); -extern void CheckPExtraOptCB(FL_OBJECT *, long); -extern void ParagraphExtraOKCB(FL_OBJECT *, long); -extern void ParagraphExtraApplyCB(FL_OBJECT *, long); -extern void ParagraphExtraCancelCB(FL_OBJECT *, long); +extern "C" void CheckPExtraOptCB(FL_OBJECT *, long); +extern "C" void ParagraphExtraOKCB(FL_OBJECT *, long); +extern "C" void ParagraphExtraApplyCB(FL_OBJECT *, long); +extern "C" void ParagraphExtraCancelCB(FL_OBJECT *, long); -extern void TableOptionsCB(FL_OBJECT *, long); -extern void TableSpeCloseCB(FL_OBJECT *, long); +extern "C" void TableOptionsCB(FL_OBJECT *, long); +extern "C" void TableSpeCloseCB(FL_OBJECT *, long); /* Additional Functions/Methods */ diff --git a/src/lyx.h b/src/lyx.h index 4dec39e7de..6677d3d37a 100644 --- a/src/lyx.h +++ b/src/lyx.h @@ -4,23 +4,23 @@ #define FD_form_title_h_ /** Callbacks, globals and object handlers **/ -extern void TimerCB(FL_OBJECT *, long); +extern "C" void TimerCB(FL_OBJECT *, long); -extern void FigureOKCB(FL_OBJECT *, long); -extern void FigureApplyCB(FL_OBJECT *, long); -extern void FigureCancelCB(FL_OBJECT *, long); +extern "C" void FigureOKCB(FL_OBJECT *, long); +extern "C" void FigureApplyCB(FL_OBJECT *, long); +extern "C" void FigureCancelCB(FL_OBJECT *, long); -extern void ScreenOKCB(FL_OBJECT *, long); -extern void ScreenApplyCB(FL_OBJECT *, long); -extern void ScreenCancelCB(FL_OBJECT *, long); +extern "C" void ScreenOKCB(FL_OBJECT *, long); +extern "C" void ScreenApplyCB(FL_OBJECT *, long); +extern "C" void ScreenCancelCB(FL_OBJECT *, long); -extern void TocSelectCB(FL_OBJECT *, long); -extern void TocCancelCB(FL_OBJECT *, long); -extern void TocUpdateCB(FL_OBJECT *, long); +extern "C" void TocSelectCB(FL_OBJECT *, long); +extern "C" void TocCancelCB(FL_OBJECT *, long); +extern "C" void TocUpdateCB(FL_OBJECT *, long); -extern void RefUpdateCB(FL_OBJECT *, long); -extern void RefHideCB(FL_OBJECT *, long); -extern void RefSelectCB(FL_OBJECT *, long); +extern "C" void RefUpdateCB(FL_OBJECT *, long); +extern "C" void RefHideCB(FL_OBJECT *, long); +extern "C" void RefSelectCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 6bea5130bc..132a446a89 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -1206,7 +1206,7 @@ void MenuPasteSelection(char at) } -void FootCB(FL_OBJECT*, long) +extern "C" void FootCB(FL_OBJECT*, long) { if (!current_view->available()) return; @@ -2305,7 +2305,7 @@ void ToggleAndShow(LyXFont const & font) } -void MarginCB(FL_OBJECT *, long) +extern "C" void MarginCB(FL_OBJECT *, long) { if (current_view->available()) { minibuffer->Set(_("Inserting margin note...")); @@ -2317,7 +2317,7 @@ void MarginCB(FL_OBJECT *, long) } -void FigureCB(FL_OBJECT *, long) +extern "C" void FigureCB(FL_OBJECT *, long) { if (fd_form_figure->form_figure->visible) { fl_raise_form(fd_form_figure->form_figure); @@ -2329,7 +2329,7 @@ void FigureCB(FL_OBJECT *, long) } -void TableCB(FL_OBJECT *, long) +extern "C" void TableCB(FL_OBJECT *, long) { if (fd_form_table->form_table->visible) { fl_raise_form(fd_form_table->form_table); @@ -2411,7 +2411,7 @@ void PasteCB() } -void MeltCB(FL_OBJECT *, long) +extern "C" void MeltCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -2428,7 +2428,7 @@ void MeltCB(FL_OBJECT *, long) // if decInc == 0, depth change taking mouse button number into account // if decInc == 1, increment depth // if decInc == -1, decrement depth -void DepthCB(FL_OBJECT *ob, long decInc) +extern "C" void DepthCB(FL_OBJECT *ob, long decInc) { int button = 1; @@ -2551,7 +2551,7 @@ void FreeCB() /* callbacks for form form_title */ -void TimerCB(FL_OBJECT *, long) +extern "C" void TimerCB(FL_OBJECT *, long) { // only if the form still exists if (fd_form_title->form_title != 0) { @@ -2566,7 +2566,7 @@ void TimerCB(FL_OBJECT *, long) /* callbacks for form form_paragraph */ -void ParagraphVSpaceCB(FL_OBJECT* obj, long ) +extern "C" void ParagraphVSpaceCB(FL_OBJECT* obj, long ) { // "Synchronize" the choices and input fields, making it // impossible to commit senseless data. @@ -2617,7 +2617,7 @@ void ParagraphVSpaceCB(FL_OBJECT* obj, long ) } -void ParagraphApplyCB(FL_OBJECT *, long) +extern "C" void ParagraphApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -2693,13 +2693,13 @@ void ParagraphApplyCB(FL_OBJECT *, long) } -void ParagraphCancelCB(FL_OBJECT *, long) +extern "C" void ParagraphCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_paragraph->form_paragraph); } -void ParagraphOKCB(FL_OBJECT *ob, long data) +extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data) { ParagraphApplyCB(ob, data); ParagraphCancelCB(ob, data); @@ -2708,7 +2708,7 @@ void ParagraphOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_character */ -void CharacterApplyCB(FL_OBJECT *, long) +extern "C" void CharacterApplyCB(FL_OBJECT *, long) { // we set toggleall locally here, since it should be true for // all other uses of ToggleAndShow() (JMarc) @@ -2718,13 +2718,13 @@ void CharacterApplyCB(FL_OBJECT *, long) } -void CharacterCloseCB(FL_OBJECT *, long) +extern "C" void CharacterCloseCB(FL_OBJECT *, long) { fl_hide_form(fd_form_character->form_character); } -void CharacterOKCB(FL_OBJECT *ob, long data) +extern "C" void CharacterOKCB(FL_OBJECT *ob, long data) { CharacterApplyCB(ob,data); CharacterCloseCB(ob,data); @@ -2755,7 +2755,7 @@ void UpdateDocumentButtons(BufferParams const ¶ms) } -void ChoiceClassCB(FL_OBJECT *ob, long) +extern "C" void ChoiceClassCB(FL_OBJECT *ob, long) { ProhibitInput(); if (lyxstyle.Load(fl_get_choice(ob)-1)) { @@ -2780,7 +2780,7 @@ void ChoiceClassCB(FL_OBJECT *ob, long) } -void DocumentDefskipCB(FL_OBJECT *obj, long) +extern "C" void DocumentDefskipCB(FL_OBJECT *obj, long) { // "Synchronize" the choice and the input field, so that it // is impossible to commit senseless data. @@ -2809,7 +2809,7 @@ void DocumentDefskipCB(FL_OBJECT *obj, long) } -void DocumentSpacingCB(FL_OBJECT *obj, long) +extern "C" void DocumentSpacingCB(FL_OBJECT *obj, long) { // "Synchronize" the choice and the input field, so that it // is impossible to commit senseless data. @@ -2831,7 +2831,7 @@ void DocumentSpacingCB(FL_OBJECT *obj, long) } -void DocumentApplyCB(FL_OBJECT *, long) +extern "C" void DocumentApplyCB(FL_OBJECT *, long) { bool redo = false; BufferParams *params = &(current_view->currentBuffer()->params); @@ -2985,20 +2985,20 @@ void DocumentApplyCB(FL_OBJECT *, long) } -void DocumentCancelCB(FL_OBJECT *, long) +extern "C" void DocumentCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_document->form_document); } -void DocumentOKCB(FL_OBJECT *ob, long data) +extern "C" void DocumentOKCB(FL_OBJECT *ob, long data) { DocumentCancelCB(ob,data); DocumentApplyCB(ob,data); } -void DocumentBulletsCB(FL_OBJECT *, long) +extern "C" void DocumentBulletsCB(FL_OBJECT *, long) { bulletForm(); // bullet callbacks etc. in bullet_panel.C -- ARRae @@ -3056,7 +3056,7 @@ void InsertCorrectQuote() /* callbacks for form form_quotes */ -void QuotesApplyCB(FL_OBJECT *, long) +extern "C" void QuotesApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -3095,13 +3095,13 @@ void QuotesApplyCB(FL_OBJECT *, long) } -void QuotesCancelCB(FL_OBJECT *, long) +extern "C" void QuotesCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_quotes->form_quotes); } -void QuotesOKCB(FL_OBJECT *ob, long data) +extern "C" void QuotesOKCB(FL_OBJECT *ob, long data) { QuotesApplyCB(ob, data); QuotesCancelCB(ob, data); @@ -3111,13 +3111,13 @@ void QuotesOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_preamble */ -void PreambleCancelCB(FL_OBJECT *, long) +extern "C" void PreambleCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_preamble->form_preamble); } -void PreambleApplyCB(FL_OBJECT *, long) +extern "C" void PreambleApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -3129,7 +3129,7 @@ void PreambleApplyCB(FL_OBJECT *, long) } -void PreambleOKCB(FL_OBJECT *ob, long data) +extern "C" void PreambleOKCB(FL_OBJECT *ob, long data) { PreambleApplyCB(ob, data); PreambleCancelCB(ob, data); @@ -3138,7 +3138,7 @@ void PreambleOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_table */ -void TableApplyCB(FL_OBJECT *, long) +extern "C" void TableApplyCB(FL_OBJECT *, long) { int xsize,ysize; if (!current_view->getScreen()) @@ -3216,13 +3216,13 @@ void TableApplyCB(FL_OBJECT *, long) } -void TableCancelCB(FL_OBJECT *, long) +extern "C" void TableCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_table->form_table); } -void TableOKCB(FL_OBJECT *ob, long data) +extern "C" void TableOKCB(FL_OBJECT *ob, long data) { TableApplyCB(ob,data); TableCancelCB(ob,data); @@ -3231,7 +3231,7 @@ void TableOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_print */ -void PrintCancelCB(FL_OBJECT *, long) +extern "C" void PrintCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_print->form_print); } @@ -3243,7 +3243,7 @@ static bool stringOnlyContains (string const & LStr, const char * cset) return strspn(cstr,cset) == strlen(cstr) ; } -void PrintApplyCB(FL_OBJECT *, long) +extern "C" void PrintApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -3406,7 +3406,7 @@ void PrintApplyCB(FL_OBJECT *, long) } -void PrintOKCB(FL_OBJECT *ob, long data) +extern "C" void PrintOKCB(FL_OBJECT *ob, long data) { PrintCancelCB(ob, data); PrintApplyCB(ob,data); @@ -3415,7 +3415,7 @@ void PrintOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_figure */ -void FigureApplyCB(FL_OBJECT *, long) +extern "C" void FigureApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -3486,19 +3486,19 @@ void FigureApplyCB(FL_OBJECT *, long) } -void FigureCancelCB(FL_OBJECT *, long) +extern "C" void FigureCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_figure->form_figure); } -void FigureOKCB(FL_OBJECT *ob, long data) +extern "C" void FigureOKCB(FL_OBJECT *ob, long data) { FigureApplyCB(ob,data); FigureCancelCB(ob,data); } -void ScreenApplyCB(FL_OBJECT *, long) +extern "C" void ScreenApplyCB(FL_OBJECT *, long) { lyxrc->roman_font_name = fl_get_input(fd_form_screen->input_roman); lyxrc->sans_font_name = fl_get_input(fd_form_screen->input_sans); @@ -3514,13 +3514,13 @@ void ScreenApplyCB(FL_OBJECT *, long) } -void ScreenCancelCB(FL_OBJECT *, long) +extern "C" void ScreenCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_screen->form_screen); } -void ScreenOKCB(FL_OBJECT *ob, long data) +extern "C" void ScreenOKCB(FL_OBJECT *ob, long data) { ScreenCancelCB(ob,data); ScreenApplyCB(ob,data); @@ -3643,7 +3643,7 @@ struct TocList { static TocList* toclist = 0; -void TocSelectCB(FL_OBJECT *ob, long) +extern "C" void TocSelectCB(FL_OBJECT *ob, long) { if (!current_view->available()) return; @@ -3687,13 +3687,13 @@ void TocSelectCB(FL_OBJECT *ob, long) } -void TocCancelCB(FL_OBJECT *, long) +extern "C" void TocCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_toc->form_toc); } -void TocUpdateCB(FL_OBJECT *, long) +extern "C" void TocUpdateCB(FL_OBJECT *, long) { static LyXParagraph* stapar = 0; TocList *tmptoclist = 0; @@ -3799,7 +3799,7 @@ void TocUpdateCB(FL_OBJECT *, long) /* callbacks for form form_ref */ -void RefSelectCB(FL_OBJECT *, long data) +extern "C" void RefSelectCB(FL_OBJECT *, long data) { if (!current_view->available()) return; @@ -3834,7 +3834,7 @@ void RefSelectCB(FL_OBJECT *, long data) } -void RefUpdateCB(FL_OBJECT *, long) +extern "C" void RefUpdateCB(FL_OBJECT *, long) { if (!current_view->available()) { fl_clear_browser(fd_form_ref->browser_ref); @@ -3903,7 +3903,7 @@ void RefUpdateCB(FL_OBJECT *, long) } -void RefHideCB(FL_OBJECT *, long) +extern "C" void RefHideCB(FL_OBJECT *, long) { fl_hide_form(fd_form_ref->form_ref); } diff --git a/src/lyx_cb.h b/src/lyx_cb.h index 2b9dfd9d6f..503733ff2b 100644 --- a/src/lyx_cb.h +++ b/src/lyx_cb.h @@ -16,7 +16,7 @@ extern bool quitting; extern bool BindFileSet; /// -extern void FootCB(FL_OBJECT *, long); +extern "C" void FootCB(FL_OBJECT *, long); /// extern void EmphCB(); /// @@ -24,17 +24,17 @@ extern void BoldCB(); /// extern void NounCB(); /// -extern void MarginCB(FL_OBJECT *, long); +extern "C" void MarginCB(FL_OBJECT *, long); /// -extern void FigureCB(FL_OBJECT *, long); +extern "C" void FigureCB(FL_OBJECT *, long); /// -extern void TableCB(FL_OBJECT *, long); +extern "C" void TableCB(FL_OBJECT *, long); /// -extern void MeltCB(FL_OBJECT *, long); +extern "C" void MeltCB(FL_OBJECT *, long); /// extern void TexCB(); /// -extern void DepthCB(FL_OBJECT *, long); +extern "C" void DepthCB(FL_OBJECT *, long); /// extern void FreeCB(); /// diff --git a/src/lyx_gui.C b/src/lyx_gui.C index 50d9b48cd1..09ea9ad82d 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -144,7 +144,7 @@ FL_resource res[] = }; -static int LyX_XErrHandler(Display *display, XErrorEvent *xeev) +extern "C" int LyX_XErrHandler(Display *display, XErrorEvent *xeev) { //#warning Please see if you can trigger this! // emergency save diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index ed3e07f494..0260d6d282 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -70,14 +70,14 @@ extern void TocUpdateCB(); extern void HideFiguresPopups(); // Prevents LyX from being killed when the close box is pressed in a popup. -int CancelCloseBoxCB(FL_FORM *, void *) +extern "C" int CancelCloseBoxCB(FL_FORM *, void *) { return FL_CANCEL; } // Prevents LyX from being killed when the close box is pressed in a popup. -int IgnoreCloseBoxCB(FL_FORM *, void *) +extern "C" int IgnoreCloseBoxCB(FL_FORM *, void *) { return FL_IGNORE; } diff --git a/src/lyx_sendfax.h b/src/lyx_sendfax.h index 271adffa41..60b3746c12 100644 --- a/src/lyx_sendfax.h +++ b/src/lyx_sendfax.h @@ -4,17 +4,17 @@ #define FD_xsendfax_h_ /** Callbacks, globals and object handlers **/ -extern void FaxSendCB(FL_OBJECT *, long); -extern void FaxCancelCB(FL_OBJECT *, long); -extern void FaxApplyCB(FL_OBJECT *, long); -extern void FaxOpenPhonebookCB(FL_OBJECT *, long); -extern void cb_add_phoneno(FL_OBJECT *, long); -extern void cb_delete_phoneno(FL_OBJECT *, long); -extern void cb_save_phoneno(FL_OBJECT *, long); +extern "C" void FaxSendCB(FL_OBJECT *, long); +extern "C" void FaxCancelCB(FL_OBJECT *, long); +extern "C" void FaxApplyCB(FL_OBJECT *, long); +extern "C" void FaxOpenPhonebookCB(FL_OBJECT *, long); +extern "C" void cb_add_phoneno(FL_OBJECT *, long); +extern "C" void cb_delete_phoneno(FL_OBJECT *, long); +extern "C" void cb_save_phoneno(FL_OBJECT *, long); -extern void cb_select_phoneno(FL_OBJECT *, long); +extern "C" void cb_select_phoneno(FL_OBJECT *, long); -extern void FaxLogfileCloseCB(FL_OBJECT *, long); +extern "C" void FaxLogfileCloseCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/mathed/math_forms.h b/src/mathed/math_forms.h index d2757c2b30..f093b96d95 100644 --- a/src/mathed/math_forms.h +++ b/src/mathed/math_forms.h @@ -4,6 +4,7 @@ #define FD_panel_h_ /** Callbacks, globals and object handlers **/ +extern "C" { extern void button_cb(FL_OBJECT *, long); extern void delim_cb(FL_OBJECT *, long); @@ -13,7 +14,7 @@ extern void matrix_cb(FL_OBJECT *, long); extern void deco_cb(FL_OBJECT *, long); extern void space_cb(FL_OBJECT *, long); - +} /**** Forms and Objects ****/ typedef struct { diff --git a/src/mathed/math_panel.C b/src/mathed/math_panel.C index 942c42cc14..959de23252 100644 --- a/src/mathed/math_panel.C +++ b/src/mathed/math_panel.C @@ -244,7 +244,7 @@ void space_cb(FL_OBJECT *, long data) } } -int align_filter(FL_OBJECT *, char const *, char const *cur, int c) +extern "C" int align_filter(FL_OBJECT *, char const *, char const *cur, int c) { int n = (int)(fl_get_slider_value(fd_matrix->columns)+0.5) - strlen(cur); return ((c=='c'||c=='l'||c=='r') && n>=0) ? FL_VALID: FL_INVALID; @@ -320,20 +320,19 @@ void free_symbols_form() } } -int AtClose_symbols_form(FL_FORM *, void *) +extern "C" int AtClose_symbols_form(FL_FORM *, void *) { free_symbols_form(); return FL_IGNORE; } - void show_symbols_form(LyXFunc *lf) { lyxfunc = lf; if (!fd_panel) { fd_panel = create_math_panel(); fl_register_raw_callback(fd_panel->panel, - ButtonPressMask|KeyPressMask, peek_event); + ButtonPressMask|KeyPressMask, C_peek_event); create_symbol_menues(fd_panel); fl_set_form_atclose(fd_panel->panel, AtClose_symbols_form, 0); } diff --git a/src/mathed/math_panel.h b/src/mathed/math_panel.h index c2a5456457..64d4de183a 100644 --- a/src/mathed/math_panel.h +++ b/src/mathed/math_panel.h @@ -35,17 +35,13 @@ enum { /// typedef FL_OBJECT* FL_OBJECTP; -extern "C" { - int peek_event(FL_FORM *, void *); -} - /// Class to manage bitmap menu bars class BitmapMenu { /// static BitmapMenu *active; /// friend int peek_event(FL_FORM *, void *); - protected: +protected: /// BitmapMenu *next, *prev; /// @@ -85,6 +81,9 @@ class BitmapMenu { int GetIndex(FL_OBJECT* ob); }; +// This is just a wrapper around peek_event() +extern "C" int C_peek_event(FL_FORM *form, void *ptr); + inline void BitmapMenu::Prev() { diff --git a/src/mathed/math_symbols.C b/src/mathed/math_symbols.C index 47d31664f9..de333c6e0b 100644 --- a/src/mathed/math_symbols.C +++ b/src/mathed/math_symbols.C @@ -23,6 +23,10 @@ #endif #include +#ifdef WITH_WARNINGS +#warning Is it safe to use 'using' unconditionnally? +#endif +using std::max; #include "lyx_main.h" #include "buffer.h" @@ -132,7 +136,7 @@ static signed char Latin2Greek[] = { }; extern char** mathed_get_pixmap_from_icon(int d); -static void math_cb(FL_OBJECT*, long); +extern "C" void math_cb(FL_OBJECT*, long); static char** pixmapFromBitmapData(char const *, int, int); void math_insert_symbol(char const* s); Bool math_insert_greek(char const c); @@ -216,7 +220,7 @@ void BitmapMenu::Create() bitmap[i]->u_vdata = this; } fl_end_form(); - fl_register_raw_callback(form, KeyPressMask, peek_event); + fl_register_raw_callback(form, KeyPressMask, C_peek_event); } int BitmapMenu::GetIndex(FL_OBJECT* ob) @@ -232,7 +236,6 @@ int BitmapMenu::GetIndex(FL_OBJECT* ob) return -1; } -extern "C" { int peek_event(FL_FORM * /*form*/, void *xev) { if (BitmapMenu::active==0) @@ -258,9 +261,14 @@ int peek_event(FL_FORM * /*form*/, void *xev) } return 0; } + +// This is just a wrapper. +extern "C" int C_peek_event(FL_FORM *form, void *ptr) { + return peek_event(form,ptr); } -static void math_cb(FL_OBJECT* ob, long data) + +extern "C" void math_cb(FL_OBJECT* ob, long data) { BitmapMenu* menu = (BitmapMenu*)ob->u_vdata; int i = menu->GetIndex(ob); diff --git a/src/mathed/math_utils.C b/src/mathed/math_utils.C index a2a25b6ef4..8609e7a9a5 100644 --- a/src/mathed/math_utils.C +++ b/src/mathed/math_utils.C @@ -54,7 +54,7 @@ struct binary_op_pair { short id, isrel; } binary_op_table[] = { { LM_ddagger, LMB_OPERATOR } }; -static int compara(const void *a, const void *b) +extern "C" int compara(const void *a, const void *b) { int i = ((binary_op_pair const *)a)->id, j = ((binary_op_pair const*)b)->id; return i - j; diff --git a/src/print_form.h b/src/print_form.h index 0a932aac06..5d5c3928b7 100644 --- a/src/print_form.h +++ b/src/print_form.h @@ -4,13 +4,13 @@ #define FD_form_print_h_ /** Callbacks, globals and object handlers **/ -extern void PrintOKCB(FL_OBJECT *, long); -extern void PrintApplyCB(FL_OBJECT *, long); -extern void PrintCancelCB(FL_OBJECT *, long); +extern "C" void PrintOKCB(FL_OBJECT *, long); +extern "C" void PrintApplyCB(FL_OBJECT *, long); +extern "C" void PrintCancelCB(FL_OBJECT *, long); -extern void SendtoOKCB(FL_OBJECT *, long); -extern void SendtoApplyCB(FL_OBJECT *, long); -extern void SendtoCancelCB(FL_OBJECT *, long); +extern "C" void SendtoOKCB(FL_OBJECT *, long); +extern "C" void SendtoApplyCB(FL_OBJECT *, long); +extern "C" void SendtoCancelCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/sp_form.h b/src/sp_form.h index f84524bcc4..1d1a16058d 100644 --- a/src/sp_form.h +++ b/src/sp_form.h @@ -4,9 +4,9 @@ #define FD_form_spell_options_h_ /** Callbacks, globals and object handlers **/ -extern void SpellOptionsOKCB(FL_OBJECT *, long); -extern void SpellOptionsCancelCB(FL_OBJECT *, long); -extern void SpellOptionsApplyCB(FL_OBJECT *, long); +extern "C" void SpellOptionsOKCB(FL_OBJECT *, long); +extern "C" void SpellOptionsCancelCB(FL_OBJECT *, long); +extern "C" void SpellOptionsApplyCB(FL_OBJECT *, long); diff --git a/src/support/DebugStream.h b/src/support/DebugStream.h index d5be8b609d..6fb383ed9f 100644 --- a/src/support/DebugStream.h +++ b/src/support/DebugStream.h @@ -22,7 +22,7 @@ #include #endif -#ifdef MODERN_STL +//#ifdef MODERN_STL using std::ostream; using std::streambuf; using std::streamsize; @@ -30,7 +30,7 @@ using std::filebuf; using std::cerr; using std::ios; using std::endl; -#endif +//#endif #ifdef TEST_DEBUGSTREAM #include diff --git a/src/support/lstrings.C b/src/support/lstrings.C index 9aa4ea0a80..18f452dcb8 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -10,6 +10,8 @@ //#include "debug.h" +using std::count; + bool isStrInt(string const & str) { if (str.empty()) return false; diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index 7d7c614ed0..32d2dd24ab 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -23,6 +23,8 @@ #include "LAssert.h" +using std::min; + // Reference count has been checked, empty_rep removed and // introduced again in a similar guise. Where is empty_rep _really_ // needed? diff --git a/src/toolbar.C b/src/toolbar.C index 4dba7ea114..fae4601c14 100644 --- a/src/toolbar.C +++ b/src/toolbar.C @@ -92,6 +92,7 @@ #include "layout_std.xpm" #include "build.xpm" +// this one is not "C" because combox callbacks are really C++ %-| extern void LayoutsCB(int, void*); extern char** get_pixmap_from_symbol(char const *arg, int, int); extern LyXAction lyxaction;