[master] 374232e - Fix MSVC 2010 and older not finding round()

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.commit  ]
 
Previous Message ]Next Message ]

[master] 374232e - Fix MSVC 2010 and older not finding round() "Albrecht Schlosser" 07:02 May 07 top right image
 
commit 374232e2f483119ef73a59159c885b483cc9325a
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Fri May 7 15:48:24 2021 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Fri May 7 15:48:24 2021 +0200

    Fix MSVC 2010 and older not finding round()
    
    Actually we don't know about some newer MSVC versions, but current
    version MSVC 2019 works fine w/o defining round(). If other MSVC
    versions need this as well we can change the version test or add
    a compiler feature test to CMake (configure not required).

 src/Fl_win32.cxx | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git src/Fl_win32.cxx src/Fl_win32.cxx
index 1e5b732..1ef76cb 100644
--- src/Fl_win32.cxx
+++ src/Fl_win32.cxx
@@ -94,6 +94,16 @@ extern void fl_trigger_clipboard_notify(int source);
 extern HBRUSH fl_brush_action(int action);
 extern void fl_cleanup_pens(void);
 
+// MSVC 2010 can't find round() although <math.h> is included above,
+// which is surprising because ceil() works fine.
+// We could (should?) probably add configure/CMake feature tests for
+// round() and ceil() rather than depending on MSVC version numbers.
+// AlbrechtS, 02/2010 - Note: we don't know about MSVC 2012 - 2015, see
+// https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
+
+#if defined(_MSC_VER) && _MSC_VER <= 1600
+#define round(A) int((A) + 0.5)
+#endif // _MSC_VER <= 1600
 
 //
 // USE_ASYNC_SELECT - define it if you have WSAAsyncSelect()...
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]Next Message ]
 
 

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