Anyone else having snprintf issues with 2017c?
The tzvalidate <https://github.com/nodatime/tzvalidate> travis build is failing, with both clang and gcc, with this error: zdump.c:803:1: error: static declaration of ‘snprintf’ follows non-static declaration snprintf(char *s, size_t size, char const *format, ...) ^ make: *** [zdump.o] Error 1 It's building fine for me locally, so I'm not quite sure what's wrong. We're currently building on trusty - I may try another distro... The snprintf changes were introduced on June 13th <https://github.com/eggert/tz/commit/399180580f65bcad63cf996997068366cadaf530...>. It's been too long since I've done a lot of C to easily work out what's going on. I'll investigate further myself tomorrow, but I thought I'd just see if anyone else had seen this before then. Jon
On Oct 23, 2017, at 2:52 PM, Jon Skeet <skeet@pobox.com> wrote:
The tzvalidate travis build is failing, with both clang and gcc, with this error:
zdump.c:803:1: error: static declaration of ‘snprintf’ follows non-static declaration snprintf(char *s, size_t size, char const *format, ...) ^ make: *** [zdump.o] Error 1
It's building fine for me locally, so I'm not quite sure what's wrong. We're currently building on trusty - I may try another distro...
The snprintf changes were introduced on June 13th. It's been too long since I've done a lot of C to easily work out what's going on. I'll investigate further myself tomorrow, but I thought I'd just see if anyone else had seen this before then.
Jon
It looks like you can work around this by building with the following as an added option for the compiler: -DHAVE_SNPRINTF Howard
Thanks - will give that a try when I've worked out what that means in terms of running make :) On 23 October 2017 at 20:08, Howard Hinnant <howard.hinnant@gmail.com> wrote:
On Oct 23, 2017, at 2:52 PM, Jon Skeet <skeet@pobox.com> wrote:
The tzvalidate travis build is failing, with both clang and gcc, with
this error:
zdump.c:803:1: error: static declaration of ‘snprintf’ follows
non-static declaration
snprintf(char *s, size_t size, char const *format, ...) ^ make: *** [zdump.o] Error 1
It's building fine for me locally, so I'm not quite sure what's wrong. We're currently building on trusty - I may try another distro...
The snprintf changes were introduced on June 13th. It's been too long since I've done a lot of C to easily work out what's going on. I'll investigate further myself tomorrow, but I thought I'd just see if anyone else had seen this before then.
Jon
It looks like you can work around this by building with the following as an added option for the compiler: -DHAVE_SNPRINTF
Howard
Adding CFLAGS=-DHAVE_SNPRINTF as an argument to make fixed it. It's a temporary hack for now, but it gets me past the immediate problem. On 23 October 2017 at 20:08, Howard Hinnant <howard.hinnant@gmail.com> wrote:
On Oct 23, 2017, at 2:52 PM, Jon Skeet <skeet@pobox.com> wrote:
The tzvalidate travis build is failing, with both clang and gcc, with
this error:
zdump.c:803:1: error: static declaration of ‘snprintf’ follows
non-static declaration
snprintf(char *s, size_t size, char const *format, ...) ^ make: *** [zdump.o] Error 1
It's building fine for me locally, so I'm not quite sure what's wrong. We're currently building on trusty - I may try another distro...
The snprintf changes were introduced on June 13th. It's been too long since I've done a lot of C to easily work out what's going on. I'll investigate further myself tomorrow, but I thought I'd just see if anyone else had seen this before then.
Jon
It looks like you can work around this by building with the following as an added option for the compiler: -DHAVE_SNPRINTF
Howard
at line 803, zdump.c has a static declaration of snprintf. That declaration is within an "#ifdef !HAVE_SNPRINTF", presumably because this function is usually included by standard system header. The error seems to indicate that now both this local version and the standard system version are picked up but they don't have the same declaration (static vs. non static). My hunch is that "#ifdef !HAVE_SNPRINTF" should not have evaluated to true for that platform. In the old days I would have suspected an issue with autoconf but here you are on your own. Presumably it's the value of __STDC_VERSION__ inside the declaration of HAVE_SNPRINTF that's causing the problem in one environment but not the other. See at line 25: #ifndef HAVE_SNPRINTF # define HAVE_SNPRINTF (199901 <= __STDC_VERSION__) #endif I don't have an environment to test this though. You might want to print __STDC_VERSION__ in both environment and see if you see a different value. On 23/10/2017 2:52 PM, Jon Skeet wrote:
The tzvalidate <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nodatime_tzv...> travis build is failing, with both clang and gcc, with this error:
zdump.c:803:1: error: static declaration of ‘snprintf’ follows non-static declaration snprintf(char *s, size_t size, char const *format, ...) ^ make: *** [zdump.o] Error 1
It's building fine for me locally, so I'm not quite sure what's wrong. We're currently building on trusty - I may try another distro...
The snprintf changes were introduced on June 13th <https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_eggert_tz_co...>. It's been too long since I've done a lot of C to easily work out what's going on. I'll investigate further myself tomorrow, but I thought I'd just see if anyone else had seen this before then.
Jon
-- Oracle Email Signature Logo Patrice Scattolin | Software Development Manager | 514.905.8744 Oracle Cloud 600 Blvd de Maisonneuve West Suite 1900 Montreal, Quebec
Patrice Scattolin <patrice.scattolin@oracle.com> writes:
Presumably it's the value of __STDC_VERSION__ inside the declaration of HAVE_SNPRINTF that's causing the problem in one environment but not the other. See at line 25:
#ifndef HAVE_SNPRINTF # define HAVE_SNPRINTF (199901 <= __STDC_VERSION__) #endif
This coding will fail on a C90 compiler that's on a platform that supplies snprintf, which is a combination I don't find real surprising --- probably "gcc -ansi" would behave that way on many machines. Apparently the expectation is that people using such platforms will manually fix things by defining HAVE_SNPRINTF=1. I'm not sure it's possible to do better without autoconf. regards, tom lane
On 10/23/2017 12:33 PM, Tom Lane wrote:
Apparently the expectation is that people using such platforms will manually fix things by defining HAVE_SNPRINTF=1.
I hadn't thought about this particular case. I thought most people were using C99-or-later platforms by now and that HAVE_SPRINTF was mostly a historical curiosity. Perhaps I'm too accustomed to life in the fast lane. But yes, compiling with -DHAVE_SNPRINTF works around the problem. I installed the attached, which I hope removes the need to specify -DHAVE_SNPRINTF with pre-C99 platforms that have snprintf, without resorting to Autoconf. Jon, could you please give it a try in your environment? Thanks.
Applying a patch isn't terribly simple in my environment, but HEAD of https://github.com/eggert/tz builds for me, yes - so assuming they're the same thing, that fixes it. Thanks! On 24 October 2017 at 02:19, Paul Eggert <eggert@cs.ucla.edu> wrote:
On 10/23/2017 12:33 PM, Tom Lane wrote:
Apparently the expectation is that people using such platforms will manually fix things by defining HAVE_SNPRINTF=1.
I hadn't thought about this particular case. I thought most people were using C99-or-later platforms by now and that HAVE_SPRINTF was mostly a historical curiosity. Perhaps I'm too accustomed to life in the fast lane. But yes, compiling with -DHAVE_SNPRINTF works around the problem.
I installed the attached, which I hope removes the need to specify -DHAVE_SNPRINTF with pre-C99 platforms that have snprintf, without resorting to Autoconf. Jon, could you please give it a try in your environment? Thanks.
On Oct 23, 2017, at 11:52 AM, Jon Skeet <skeet@pobox.com> wrote:
The tzvalidate travis build is failing, with both clang and gcc, with this error:
zdump.c:803:1: error: static declaration of ‘snprintf’ follows non-static declaration
The .travis.yml file says dist: trusty I'm assuming that's Ubuntu Trusty Tahr, which I would expect to have C compilers that support C99 and a libc that includes snprintf(). However, I'm not sure the compiler would *default* to C99; perhaps you need to compile with -std=c99 rather than, say, -ansi, which may default to C90 rather than C99.
On 2017-10-23 20:14, Guy Harris wrote:
On Oct 23, 2017, at 11:52 AM, Jon Skeet <skeet@pobox.com> wrote:
The tzvalidate travis build is failing, with both clang and gcc, with this error:
zdump.c:803:1: error: static declaration of ‘snprintf’ follows non-static declaration
The .travis.yml file says
dist: trusty
I'm assuming that's Ubuntu Trusty Tahr, which I would expect to have C compilers that support C99 and a libc that includes snprintf().
Release compiler from trusty-updates is: $ gcc --version gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4 Copyright (C) 2013 Free Software Foundation, Inc. for baseline trusty it is 4.8.2, for Xenial it is 5.3.1, Yakkety 6.1.1, Zesty 6.3.0, same as Debian Stretch; Debian Sid is at 7.2.0.
However, I'm not sure the compiler would *default* to C99; perhaps you need to compile with -std=c99 rather than, say, -ansi, which may default to C90 rather than C99. Default is -std=gnu90 - from "info gcc option std=" - c99/c11 support was incomplete; "info gcc Standards" says compliance is issuing required diagnostics with -std=c## -Wpedantic. Actual standards support is always evolving, and dependent on the available library i.e. GNU glibc, BSD libc, musl, Redhat/Sourceware newlib, uClibc-ng, etc.
Unless the code compiles with no warnings using -ansi -pedantic, and then builds successfully, I'd compile with -std=gnu11 -Wall -Wextra for maximum flexibility. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
participants (7)
-
Brian Inglis -
Guy Harris -
Howard Hinnant -
Jon Skeet -
Patrice Scattolin -
Paul Eggert -
Tom Lane