eserte / perl-tk

the perl module Tk
https://metacpan.org/release/Tk
Other
44 stars 33 forks source link

../pTk/mTk/xlib/X11/X.h:182:34: error: expected identifier or '(' before numeric constant #87

Open hakonhagland opened 2 years ago

hakonhagland commented 2 years ago

I have installed a debug version of perl 5.37.5 on Windows 11 using MinGW-w64 and gcc 11.3 from https://winlibs.com/ (using the MSVCRT runtime library), see https://github.com/Perl/perl5/issues/20395 for more information on this.

When trying to install Tk with this perl I get:

>perl --version
This is perl 5, version 37, subversion 5 (v5.37.5-8-g382a566379) built for MSWin32-x64-multi-thread
[...]
>perl Makefile.PL
[...]
>gmake
[...]
gcc -c -I. -I./pTk/mTk/xlib  -I.. -I.. -I../pTk/mTk/xlib -I. -Ibitmaps -I.. -I../pTk/mTk/xlib -DWIN32 -DWIN64 -DDEBUGGING -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -DPERLDLL -g -O0   -DVERSION=\"804.036\" -DXS_VERSION=\"804.036\"  "-IC:\perl-debug\lib\CORE"    exWinHandle.c
gcc -c -I. -I./pTk/mTk/xlib  -I.. -I.. -I../pTk/mTk/xlib -I. -Ibitmaps -I.. -I../pTk/mTk/xlib -DWIN32 -DWIN64 -DDEBUGGING -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -DPERLDLL -g -O0   -DVERSION=\"804.036\" -DXS_VERSION=\"804.036\"  "-IC:\perl-debug\lib\CORE"    imgBMP.c
In file included from ../pTk/mTk/xlib/X11/Xlib.h:31,
                 from tkWinPort.h:19,
                 from tkPort.h:32,
                 from tk.h:87,
                 from imgBMP.c:11:
../pTk/mTk/xlib/X11/X.h:182:34: error: expected identifier or '(' before numeric constant
  182 | #define ControlMask             (1<<2)
      |                                  ^
gmake[1]: *** [makefile:891: imgBMP.o] Error 1
gmake[1]: Leaving directory 'C:/Users/hakon/perl/cpan-modules/Tk-804.036/pTk'
gmake: *** [makefile:1656: pTk/libpTk.a] Error 2

The complete output from the last two commands is here: perl-makefile.log, and gmake.log

A wild guess could be that this error happens because X.h, see line 182 defines ControlMask whereas ControlMask is already typedef'ed in another header file (processthreadsapi.h) pulled in from windows.h. I cannot find this header file as direct link online, but locally it is located in C:\Winlibs64-gcc11.3-msvcrt\mingw64\include. At line 163 of that file I have this typedef:

typedef struct _PROCESS_POWER_THROTTLING_STATE {
    ULONG Version;
    ULONG ControlMask;
    ULONG StateMask;
  } PROCESS_POWER_THROTTLING_STATE, *PPROCESS_POWER_THROTTLING_STATE;
hakonhagland commented 2 years ago

could be that this error happens because X.h, see line 182 defines ControlMask whereas ControlMask is already typedef'ed in another header file

Yes, I think this is the case. See pull #88 for a possible fix.

chrstphrchvz commented 2 years ago

This issue was already addressed by upstream Tcl/Tk, see https://core.tcl-lang.org/tk/info/9e31fd9449

I would prefer that Perl/Tk backport their approach for consistency; I will open a PR to do so.