Windows build failures
Hello Paul, I noticed new Windows build failures with the latest tz code from git. Hopefully you can shed some light on these. Error 1 d:\iana\tmp\private.h(704): error C2373: 'restrict': redefinition; different type modifiers d:\iana\tmp\private.h(704): note: see declaration of 'restrict' d:\iana\tmp\private.h(780): error C2373: 'restrict': redefinition; different type modifiers d:\iana\tmp\private.h(780): note: see declaration of 'restrict' d:\iana\tmp\private.h(781): error C2371: 'restrict': redefinition; different basic types d:\iana\tmp\private.h(780): note: see declaration of 'restrict' Error 2 zic.c(154): error C2146: syntax error: missing ')' before identifier 'file' zic.c(154): error C2061: syntax error: identifier 'file' zic.c(154): error C2059: syntax error: ';' zic.c(154): error C2059: syntax error: ',' zic.c(154): error C2059: syntax error: ')' Thank you! Kind Regards Manuela Friedrich
On 12/19/22 01:23, Manuela Friedrich wrote:
I noticed new Windows build failures with the latest tz code from git. Hopefully you can shed some light on these.
Error 1
d:\iana\tmp\private.h(704): error C2373: 'restrict': redefinition; different type modifiers d:\iana\tmp\private.h(704): note: see declaration of 'restrict'
This line should be compiled only if you're building with -DHAVE_DECL_ASCTIME_R=0, which you should be using only if <time.h> does not declare asctime_r. But evidently your<time.h> does declare asctime_r or otherwise you wouldn't be getting that diagnostic. So I suggest dropping -DHAVE_DECL_ASCTIME_R=0 from your build flags. Or, if my diagnosis is incorrect, let's see the output of 'cc -E' to see what's going wrong here.
d:\iana\tmp\private.h(780): error C2373: 'restrict': redefinition; different type modifiers d:\iana\tmp\private.h(780): note: see declaration of 'restrict'
This one is more of a mystery, as this is localtime_rz. Does MS-Windows define its own localtime_rz? If not, what declaration of localtime_rz collides with this one? Again, you may need to run 'cc -E' to see what's going on, by looking at the preprocessor output.
Oh, one more thing. If you compile with /std:c11 or /std:c17, does that fix the problem? If so, perhaps we should just recommend that somewhere. If not, I have some more questions: How about if you instead compile with -DPORT_TO_C89? I am asking these questions because of the following recently-changed code in private.h: #if PORT_TO_C89 && __STDC_VERSION__ < 199901 && !defined restrict # define restrict /* empty */ #endif Perhaps the "#define restrict /* empty */" is needed in your Microsoft-based setup. I have some other questions about your compiler, assuming you don't use any of the above flags: What is the value of __STDC_VERSION__ on your platform? And what is the value of _MSC_VER? Does "#include <stdbool.h>" work? Does "#include <inttypes.h>" work? How about "#include <stdint.h>"? Is there a snprintf function?
Hello Paul, I did feel like there was something up with restrict causing these issues. Adding #define restrict /* empty */ in private.h helped build everything successfully. So I wonder if you can decouple the new condition to set restrict to empty as it is causing the windows issues. #if PORT_TO_C89 && __STDC_VERSION__ < 199901 && !defined restrict # define restrict /* empty */ #endif We are compiling with nmake from Visual Studio 2017. _MSC_VER is 1912 __STDC_VERSION__ is not defined Regards Manuela Friedrich -----Original Message----- From: Paul Eggert <eggert@cs.ucla.edu> Sent: Dienstag, 20. Dezember 2022 05:31 To: Manuela Friedrich <Manuela.Friedrich@actian.com>; tz@iana.org Cc: Steven Shuriff <Steven.Shuriff@actian.com> Subject: Re: Windows build failures Oh, one more thing. If you compile with /std:c11 or /std:c17, does that fix the problem? If so, perhaps we should just recommend that somewhere. If not, I have some more questions: How about if you instead compile with -DPORT_TO_C89? I am asking these questions because of the following recently-changed code in private.h: #if PORT_TO_C89 && __STDC_VERSION__ < 199901 && !defined restrict # define restrict /* empty */ #endif Perhaps the "#define restrict /* empty */" is needed in your Microsoft-based setup. I have some other questions about your compiler, assuming you don't use any of the above flags: What is the value of __STDC_VERSION__ on your platform? And what is the value of _MSC_VER? Does "#include <stdbool.h>" work? Does "#include <inttypes.h>" work? How about "#include <stdint.h>"? Is there a snprintf function?
On 12/20/22 01:42, Manuela Friedrich wrote:
So I wonder if you can decouple the new condition to set restrict to empty as it is causing the windows issues.
Sure, I installed the attached; please give it a try. What this means is that when we eventually remove the PORT_TO_C89 code (because we no longer need to worry about porting to C89 in general), we'll still need to keep this "#define restrict /*empty*/" bit to be used only with Visual Studio, as a last little vestige of C89. Not that I'm a big fan of "restrict". All things considered I'm more in the camp of Dennis Ritchie, who famously wrote, "Noalias must go. This is non-negotiable." <https://www.lysator.liu.se/c/dmr-on-noalias.html> Although Ritchie won that battle in C89, eventually he lost the war, as C99's "restrict" is essentially "noalias" by another name.
Hello Paul, This is working well! Thank you! Regards Manuela Friedrich -----Original Message----- From: Paul Eggert <eggert@cs.ucla.edu> Sent: Dienstag, 20. Dezember 2022 20:22 To: Manuela Friedrich <Manuela.Friedrich@actian.com> Cc: Steven Shuriff <Steven.Shuriff@actian.com>; Time zone mailing list <tz@iana.org> Subject: Re: Windows build failures On 12/20/22 01:42, Manuela Friedrich wrote:
So I wonder if you can decouple the new condition to set restrict to empty as it is causing the windows issues.
Sure, I installed the attached; please give it a try. What this means is that when we eventually remove the PORT_TO_C89 code (because we no longer need to worry about porting to C89 in general), we'll still need to keep this "#define restrict /*empty*/" bit to be used only with Visual Studio, as a last little vestige of C89. Not that I'm a big fan of "restrict". All things considered I'm more in the camp of Dennis Ritchie, who famously wrote, "Noalias must go. This is non-negotiable." <https://www.lysator.liu.se/c/dmr-on-noalias.html> Although Ritchie won that battle in C89, eventually he lost the war, as C99's "restrict" is essentially "noalias" by another name.
participants (2)
-
Manuela Friedrich -
Paul Eggert