Menu

#758 Compilation fix for mingw64

Bug
closed-fixed
Scintilla (812)
5
2009-04-28
2009-01-17
No

One of wxWidgets users has submitted the following patch to fix compilation of the version of Scintilla included in wxWidgets with mingw64:

Index: src/stc/scintilla/include/Scintilla.h

--- src/stc/scintilla/include/Scintilla.h (revision 58144)
+++ src/stc/scintilla/include/Scintilla.h (working copy)
@@ -28,7 +28,11 @@
#if defined(_MSC_VER) && _MSC_VER >= 1300
#include <BaseTsd.h>
#endif
-#ifdef MAXULONG_PTR
+#if defined(__MINGW64__)
+#include <stdint.h>
+typedef uint64_t uptr_t;
+typedef int64_t sptr_t;
+#elif defined(MAXULONG_PTR)
typedef ULONG_PTR uptr_t;
typedef LONG_PTR sptr_t;
#else

Could you please apply it to the official Scintilla version too?

TIA!

Discussion

  • Neil Hodgson

    Neil Hodgson - 2009-01-19

    The version of Mingw32 I have installed (GCC=3.4.2) includes an equivalent BaseTsd.h to Visual Studio and Borland which defines ULONG_PTR and LONG_PTR. These should be in Mingw64 as well. Since Mingw is trying to be Windows API friendly I would think these are better definitions to use. Then the change would be to change the guard around including BaseTSD to allow either Mingw32 or Mingw64 as well as MSC. While BaseTsd.h may not have been present in old versions of Mingw, it is easy to upgrade Mingw. The simplest change appears to me to be to always include BaseTsd.h on Windows. Windows is indicated by _WIN32 being defined which it is for 64 bit Windows. Thus,

    #if defined(_MSC_VER) && _MSC_VER >= 1300

    is changed to

    #if defined(_WIN32)

     
  • Neil Hodgson

    Neil Hodgson - 2009-01-19
    • assigned_to: nobody --> nyamatongwe
     
  • Vadim Zeitlin

    Vadim Zeitlin - 2009-01-19

    Thanks, I didn't know that the other compilers provided basetsd.h as well but if they do it definitely makes sense to use it. I've changed it as you proposed for wx itself, let's see if any other compilers users (we also support OpenWatcom and Digital Mars) complain.

     
  • Vadim Zeitlin

    Vadim Zeitlin - 2009-04-24

    Just FYI, it turns out that not all compilers have basetsd.h finally (at least Digital Mars and some versions of mingw do not) so finally in wxWidgets we simply include windows.h which will include basetsd.h too and/or define LONG_PTR in some other way.

     
  • Neil Hodgson

    Neil Hodgson - 2009-04-24
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2009-04-24

    The problem with including windows.h is that it is a huge set of headers and slows compilation down a lot.

     
  • Neil Hodgson

    Neil Hodgson - 2009-04-28

    Fix released in 1.78

     
  • Neil Hodgson

    Neil Hodgson - 2009-04-28
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.