Menu

#1737 Fix building with MinGW when using -std=c++NN

Bug
closed-invalid
None
5
2015-06-15
2015-06-14
No

Currently Scintilla can't be built with (classic, i.e. not the one from MinGW-w64 project) MinGW in "strict ANSI" mode which is enabled using -ansi or, perhaps less expectedly, -std=c++98 or -std=c++11 g++ options because of its use of non-standard isascii() function. There is a simple workaround of using -std=gnu++98 or -std=gnu++11 instead, but it's only simple if you know about it in the first place and it's not that difficult to allow things to work out of the box as it can be done with this simple patch:

diff --git a/include/Scintilla.h b/include/Scintilla.h
index 462f5b5..08acc54 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -42,6 +42,17 @@

 typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam);

+/* Workaround for building with MinGW (not MinGW-w64) in strict ANSI mode which
+ * is, notably, enabled by -std=c++NN options. */
+#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) && defined(__STRICT_ANSI__)
+/* Other headers included by an application using Scintilla might already
+ * define isascii() too, for the same reasons, try to play nicely with the. */
+#ifndef isascii
+inline int isascii(int c) { return !(c & ~0x7F); }
+#define isascii isascii
+#endif
+#endif
+
 /* ++Autogenerated -- start of section automatically generated from Scintilla.iface */
 #define INVALID_POSITION -1
 #define SCI_START 2000

It would be nice if you could please include it, TIA!

Discussion

  • Neil Hodgson

    Neil Hodgson - 2015-06-14

    Scintilla builds fine for me with MinGW and -ansi. All occurrences of isascii were removed with revision 4687 2 years ago.

     
  • Vadim Zeitlin

    Vadim Zeitlin - 2015-06-15

    I'm awfully sorry, I'm usually not that careless but for some reason I was convinced we (wxWidgets) had just recently upgraded to the latest Scintilla. Turns out we were just planning to do it but didn't do it yet, so this ticket completely out of date, sorry again. Please close it (it seems that I can't do it myself for some reason).

     
  • Neil Hodgson

    Neil Hodgson - 2015-06-15
    • status: open --> closed-invalid
    • assigned_to: Neil Hodgson
     

Log in to post a comment.