groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FWD: [bug #59276] [PATCH] #include "config.h" before <stdio.h>


From: Ingo Schwarze
Subject: FWD: [bug #59276] [PATCH] #include "config.h" before <stdio.h>
Date: Thu, 15 Oct 2020 15:39:29 +0200
User-agent: Mutt/1.12.2 (2019-09-21)

Hi,

here is the third fatal build error i encountered while trying to
build from git on OpenBSD, this time caused by the recent gnulib
update.

I'm looking for an OK to push the patch appended below.
I think it can (and should) go in before release because
including "config.h" in a few additional files is unlikely
to cause regressions with compilers that do not require it.

Yours,
  Ingo


----- Forwarded message from Ingo Schwarze <INVALID.NOREPLY@gnu.org> -----

URL:
  <https://savannah.gnu.org/bugs/?59276>

                 Summary: [PATCH] #include "config.h" before <stdio.h>
                 Project: GNU troff
            Submitted by: schwarze
            Submitted on: Thu 15 Oct 2020 01:27:04 PM UTC
                Category: Core
                Severity: 3 - Normal
              Item Group: Build/Installation
                  Status: None
                 Privacy: Public
             Assigned to: schwarze
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: [1.23]

    _______________________________________________________

Details:

Since the gnulib commit 182afcba2635cbff91240656c7fb3742dd23ab6f
  Author: Bruno Haible <bruno@clisp.org>
  Date: Sat Feb 22 20:57:30 2020 +0100
gnulib/lib/stdio.in.h uses the "restrict" keyword.

For example with GCC 4.2.1, this may cause the build to fail with a message
like this:

  In file included from ../src/libs/libgroff/assert.cpp:19:
  ./lib/stdio.h:851: error: expected ',' or '...' before 'fp'
  ./lib/stdio.h:851: error: format string argument not a string type
  ./lib/stdio.h:851: error: nonnull argument with out-of-range operand number
(argument 1, operand 2)
  ./lib/stdio.h: In function 'void assertion_failed(int, const char*, const
char*, const char*)':
  ./lib/stdio.h:851: error: too many arguments to function 'int
rpl_fprintf(FILE*)'
  ../src/libs/libgroff/assert.cpp:29: error: at this point in file
  ./lib/stdio.h:851: error: too many arguments to function 'int
rpl_fprintf(FILE*)'
  ../src/libs/libgroff/assert.cpp:31: error: at this point in file
  *** Error 1 in . (Makefile:6874 'src/libs/libgroff/libgroff_aassert.o':
@echo "  CXX     " src/libs/libgroff /libgroff_a-assert.o;g++ -DHAVE...)
  *** Error 2 in /co/groff/build (Makefile:5317 'all')

The attached patch fixes the build failure by making sure "restict" is
appropriately #defined (if needed) before the gnulib version of <stdio.h> is
included.

    _______________________________________________________


commit b0ed768a3b121f75d2c018a8c85267f749251553
Author: Ingo Schwarze <schwarze@openbsd.org>
Date:   Thu Oct 15 15:12:20 2020 +0200

     #include "config.h" before <stdio.h>
    
    Required with e.g. gcc 4.2.1 because gnulib/lib/stdio.in.h
    uses the "restrict" keyword since this gnulib commit:
    commit 182afcba2635cbff91240656c7fb3742dd23ab6f
    Author: Bruno Haible <bruno@clisp.org>
    Date: Sat Feb 22 20:57:30 2020 +0100
    
    Otherwise, the build may die from the declaration of
    various printf-like functions with messages like:
    ./lib/stdio.h:851: error: expected ',' or '...' before 'fp'
    
    * src/libs/libgroff/assert.cpp, src/libs/libgroff/errarg.cpp,
    src/libs/libgroff/error.cpp, src/preproc/eqn/eqn.ypp:
     #include "config.h".

diff --git a/ChangeLog b/ChangeLog
index d1887cb3..6accf43a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2020-10-15  Ingo Schwarze <schwarze@openbsd.org>
+
+       #include "config.h" before <stdio.h>
+
+       Required with e.g. gcc 4.2.1 because gnulib/lib/stdio.in.h
+       uses the "restrict" keyword since this gnulib commit:
+       commit 182afcba2635cbff91240656c7fb3742dd23ab6f
+       Author: Bruno Haible <bruno@clisp.org>
+       Date: Sat Feb 22 20:57:30 2020 +0100
+
+       Otherwise, the build may die from the declaration of
+       various printf-like functions with messages like:
+       ./lib/stdio.h:851: error: expected ',' or '...' before 'fp'
+
+       * src/libs/libgroff/assert.cpp, src/libs/libgroff/errarg.cpp,
+       src/libs/libgroff/error.cpp, src/preproc/eqn/eqn.ypp:
+       #include "config.h".
+
 2020-10-14  Ingo Schwarze <schwarze@openbsd.org>
 
        In groff(1), fix the combination of -v with -k, -j, and -J.
diff --git a/src/libs/libgroff/assert.cpp b/src/libs/libgroff/assert.cpp
index 80a99463..1f6bf59a 100644
--- a/src/libs/libgroff/assert.cpp
+++ b/src/libs/libgroff/assert.cpp
@@ -16,6 +16,10 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include "assert.h"
diff --git a/src/libs/libgroff/errarg.cpp b/src/libs/libgroff/errarg.cpp
index b0df24ab..ec5eae17 100644
--- a/src/libs/libgroff/errarg.cpp
+++ b/src/libs/libgroff/errarg.cpp
@@ -17,6 +17,10 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include "assert.h"
 #include "errarg.h"
diff --git a/src/libs/libgroff/error.cpp b/src/libs/libgroff/error.cpp
index 14949b91..912112b2 100644
--- a/src/libs/libgroff/error.cpp
+++ b/src/libs/libgroff/error.cpp
@@ -17,6 +17,10 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/preproc/eqn/eqn.ypp b/src/preproc/eqn/eqn.ypp
index fb318c3d..6825afb5 100644
--- a/src/preproc/eqn/eqn.ypp
+++ b/src/preproc/eqn/eqn.ypp
@@ -16,6 +16,10 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 %{
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]