summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2018-04-24 14:12:46 -0400
committerSteve Hay <steve.m.hay@googlemail.com>2018-05-24 13:16:31 +0100
commita385474c9667eb0a1b5fbba5f817d90686929349 (patch)
treeefecd1ad7359a3ec16fae72aa85e746ee074d2a9
parent636adee66dd861ad7cbeac765ffcabebc9daaaed (diff)
downloadperl-a385474c9667eb0a1b5fbba5f817d90686929349.tar.gz
fix Mingw GCC C++ build errors PL_inf/PL_nan
Trying a USE_CPLUSPLUS=define build with dmake (USE_CPLUSPLUS not implemented in GNUMakefile) causes the following error --------- gcc -c -xc++ -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -s -O2 -fwrapv - fno-strict-aliasing -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL -omini\globals.o .. \globals.c In file included from ..\globals.c:32:0: ..\perl.h:6754:50: error: too many initializers for 'U8 [8] {aka unsigned char [ 8]}' INFNAN_U8_NV_DECL PL_inf = { { LONGDBLINFBYTES } }; ^ ..\perl.h:6790:50: error: too many initializers for 'U8 [8] {aka unsigned char [ 8]}' INFNAN_U8_NV_DECL PL_nan = { { LONGDBLNANBYTES } }; ^ dmake: Error code 129, while making 'mini\globals.o' --------- in plain C mode builds, this error was just a warning and nobody paid attention to it for a while --------- gcc -c -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -s -O2 -fwrapv -fno-s trict-aliasing -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL -omini\globals.o ..\glob als.c In file included from ..\globals.c:32:0: ..\perl.h:5432:42: warning: excess elements in array initializer #define INFNAN_U8_NV_DECL EXTCONST union { U8 u8[NVSIZE]; NV nv; } ^ ..\perl.h:6754:1: note: in expansion of macro 'INFNAN_U8_NV_DECL' INFNAN_U8_NV_DECL PL_inf = { { LONGDBLINFBYTES } }; ^ ..\perl.h:5432:42: warning: (near initialization for 'PL_inf.u8') #define INFNAN_U8_NV_DECL EXTCONST union { U8 u8[NVSIZE]; NV nv; } ^ ..\perl.h:6754:1: note: in expansion of macro 'INFNAN_U8_NV_DECL' INFNAN_U8_NV_DECL PL_inf = { { LONGDBLINFBYTES } }; ^ ..\perl.h:5432:42: warning: excess elements in array initializer #define INFNAN_U8_NV_DECL EXTCONST union { U8 u8[NVSIZE]; NV nv; } ^ ------------- Now on VC C++ build, LONGDBLINFBYTES is 8 bytes, as defined in LONGDBLINFBYTES macro in config_H.vc, and for VC, "long double" is always typedefed by the CC to "double", so there was no warning, but on GCC, "long double" is the 80 bit/10 byte type and in config_H.gc the 12 byte version of INF is inside LONGDBLINFBYTES macro. Because LONG_DOUBLESIZE define was previously "8" because of makefile logic regardless of CC, # elif NVSIZE == LONG_DOUBLESIZE && defined(LONGDBLINFBYTES) INFNAN_U8_NV_DECL PL_inf = { { LONGDBLINFBYTES } }; was being hit on GCC, even though NVSIZE is 8 as it should be, but LONGDBLINFBYTES was 12. Hence the warning. I didnt research why this warning on GCC didn't cause test failures. Perhaps full perl recomputes the correct initializer in config_sh.PL and doesn't rely on what was in the miniperl initializer for PL_inf. To fix things, always emit the correct value for LONG_DOUBLESIZE and dont hardcode it at 8 for miniperl. 8 must stay for all VCs, and 12/16 is for GCC. Although GNUMakefile doesn't support a USE_CPLUSPLUS build option, it has provisons to support it one day. To keep things in sync, copy miniperl config.h append changes from makefile.mk to GNUMakefile. Also collapse 2 shell cmd lines in "ifeq ($(USE_LONG_DOUBLE),define)" to reduce number of proc launches of cmd.exe by the maketool (perf issue). Next C++ build issue. APItest.xs: In function 'void XS_XS__APItest__Backrefs_Comctl32Version(Perl Interpreter*, CV*)': APItest.xs:6806:37: error: cast from 'LPSTR {aka char*}' to 'WORD {aka shor t unsigned int}' loses precision [-fpermissive] MAKEINTRESOURCE(VS_FILE_INFO)); ^ dmake: Error code 129, while making 'APItest.o' VS_FILE_INFO is internally "RT_VERSION" which is MAKEINTRESOURCE(16). The output type of MAKEINTRESOURCE is a char *. GCC complains about casting that char * back down to a WORD (aka short). Put in a size_t used for pointer arithimitic to silence the error. Another option is to remove the outer MAKEINTRESOURCE in APItest.xs since RT_VERSION has MAKEINTRESOURCE internally, but that assumes implementation details of headers so pick the less dependency on header design option.
-rw-r--r--ext/XS-APItest/APItest.pm2
-rw-r--r--ext/XS-APItest/APItest.xs2
-rw-r--r--win32/GNUmakefile23
-rw-r--r--win32/makefile.mk23
4 files changed, 28 insertions, 22 deletions
diff --git a/ext/XS-APItest/APItest.pm b/ext/XS-APItest/APItest.pm
index b98ccf848b..07ff377dcf 100644
--- a/ext/XS-APItest/APItest.pm
+++ b/ext/XS-APItest/APItest.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Carp;
-our $VERSION = '0.97';
+our $VERSION = '0.98';
require XSLoader;
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index 15b95eb211..a30659f14f 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -6779,7 +6779,7 @@ Comctl32Version()
if(!dll)
croak("Comctl32Version: comctl32.dll not in process???");
hrsc = FindResource(dll, MAKEINTRESOURCE(VS_VERSION_INFO),
- MAKEINTRESOURCE(VS_FILE_INFO));
+ MAKEINTRESOURCE((Size_t)VS_FILE_INFO));
if(!hrsc)
croak("Comctl32Version: comctl32.dll no version???");
ver = LoadResource(dll, hrsc);
diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index 1658f9a0f4..69a72adf66 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -1336,6 +1336,11 @@ else
echo #define Off_t_size ^4)>> config.h
endif
ifeq ($(WIN64),define)
+ifeq ($(CCTYPE),GCC)
+ @(echo #define LONG_DOUBLESIZE ^16)>> config.h
+else
+ @(echo #define LONG_DOUBLESIZE ^8)>> config.h
+endif
@(echo #define PTRSIZE ^8&& \
echo #define SSize_t $(INT64)&& \
echo #define HAS_ATOLL&& \
@@ -1343,6 +1348,11 @@ ifeq ($(WIN64),define)
echo #define HAS_STRTOULL&& \
echo #define Size_t_size ^8)>> config.h
else
+ifeq ($(CCTYPE),GCC)
+ @(echo #define LONG_DOUBLESIZE ^12)>> config.h
+else
+ @(echo #define LONG_DOUBLESIZE ^8)>> config.h
+endif
@(echo #define PTRSIZE ^4&& \
echo #define SSize_t int&& \
echo #undef HAS_ATOLL&& \
@@ -1394,15 +1404,9 @@ ifeq ($(USE_LONG_DOUBLE),define)
echo #define PERL_PRIgldbl "Lg"&& \
echo #define PERL_PRIeldbl "Le"&& \
echo #define PERL_SCNfldbl "Lf"&& \
- echo #define NVTYPE long double)>> config.h
-ifeq ($(WIN64),define)
- @(echo #define NVSIZE ^16&& \
- echo #define LONG_DOUBLESIZE ^16)>> config.h
-else
- @(echo #define NVSIZE ^12&& \
- echo #define LONG_DOUBLESIZE ^12)>> config.h
-endif
- @(echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0&& \
+ echo #define NVTYPE long double&& \
+ echo #define NVSIZE LONG_DOUBLESIZE&& \
+ echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0&& \
echo #define NVef "Le"&& \
echo #define NVff "Lf"&& \
echo #define NVgf "Lg"&& \
@@ -1421,7 +1425,6 @@ else
echo #undef PERL_SCNfldbl&& \
echo #define NVTYPE double&& \
echo #define NVSIZE ^8&& \
- echo #define LONG_DOUBLESIZE ^8&& \
echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0&& \
echo #define NVef "e"&& \
echo #define NVff "f"&& \
diff --git a/win32/makefile.mk b/win32/makefile.mk
index d27e06458b..0b129c3331 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -1287,6 +1287,11 @@ $(MINIDIR)\.exists : $(CFGH_TMPL)
echo #define Off_t_size ^4)>> config.h
.ENDIF
.IF "$(WIN64)"=="define"
+.IF "$(CCTYPE)" == "GCC"
+ @(echo #define LONG_DOUBLESIZE ^16)>> config.h
+.ELSE
+ @(echo #define LONG_DOUBLESIZE ^8)>> config.h
+.ENDIF
@(echo #define PTRSIZE ^8&& \
echo #define SSize_t $(INT64)&& \
echo #define HAS_ATOLL&& \
@@ -1294,6 +1299,11 @@ $(MINIDIR)\.exists : $(CFGH_TMPL)
echo #define HAS_STRTOULL&& \
echo #define Size_t_size ^8)>> config.h
.ELSE
+.IF "$(CCTYPE)" == "GCC"
+ @(echo #define LONG_DOUBLESIZE ^12)>> config.h
+.ELSE
+ @(echo #define LONG_DOUBLESIZE ^8)>> config.h
+.ENDIF
@(echo #define PTRSIZE ^4&& \
echo #define SSize_t int&& \
echo #undef HAS_ATOLL&& \
@@ -1345,15 +1355,9 @@ $(MINIDIR)\.exists : $(CFGH_TMPL)
echo #define PERL_PRIgldbl "Lg"&& \
echo #define PERL_PRIeldbl "Le"&& \
echo #define PERL_SCNfldbl "Lf"&& \
- echo #define NVTYPE long double)>> config.h
-.IF "$(WIN64)"=="define"
- @(echo #define NVSIZE ^16&& \
- echo #define LONG_DOUBLESIZE ^16)>> config.h
-.ELSE
- @(echo #define NVSIZE ^12&& \
- echo #define LONG_DOUBLESIZE ^12)>> config.h
-.ENDIF
- @(echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0&& \
+ echo #define NVTYPE long double&& \
+ echo #define NVSIZE LONG_DOUBLESIZE&& \
+ echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0*2.0&& \
echo #define NVef "Le"&& \
echo #define NVff "Lf"&& \
echo #define NVgf "Lg"&& \
@@ -1372,7 +1376,6 @@ $(MINIDIR)\.exists : $(CFGH_TMPL)
echo #undef PERL_SCNfldbl&& \
echo #define NVTYPE double&& \
echo #define NVSIZE ^8&& \
- echo #define LONG_DOUBLESIZE ^8&& \
echo #define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0&& \
echo #define NVef "e"&& \
echo #define NVff "f"&& \