bugGNU Octave - Bugs: bug #43171, libgnu/stdio.h is included in an...


bug #43171: libgnu/stdio.h is included in an illegal way

Submitted by:  None
Submitted on:  Mon 08 Sep 2014 02:36:04 PM UTC  
Category:  Configuration and Build System Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build Failure
Status:  Fixed Assigned to:  None
Originator Name:  Johannes Zarl Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  3.8.2
Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 18 Sep 2014 12:05:58 AM UTC, comment #4: 

Petr: this bug has been fixed. If you're seeing a similar but not quite the same problem, you should probably report a new bug.

You might also look at bug #43063. That bug is actually closer to what you are seeing, that gnulib header files are included from SuiteSparse inside of an extern "C" block.

Mike Miller <mtmiller>
Project Administrator
Wed 17 Sep 2014 09:47:45 PM UTC, comment #3: 

I'm having the same issue, but it comes from the different file (i mean it's different from those discussed on http://octave.1599824.n4.nabble.com/Build-issues-with-libgnu-td4666148.html).

It goes like this

icpc ... -c numeric/SparseCmplxCHOL.cc -o numeric/.libs/numeric_libnumeric_la-SparseCmplxCHOL.o
In file included from /usr/include/cholmod_check.h(70),
                 from /usr/include/cholmod.h(95),
                 from ./util/oct-sparse.h(73),
                 from numeric/sparse-base-chol.h(27),
                 from numeric/SparseCmplxCHOL.h(27),
                 from numeric/SparseCmplxCHOL.cc(28):
../libgnu/stdio.h(948): error: declaration is incompatible with previous "getchar" (declared at line 538 of "/usr/include/stdio.h")
  _GL_CXXALIAS_SYS (getchar, int, (void));

And the same thing for putchar and vprintf functions.

It's compiled after modifying line 23 in gnulib/stdio.h by adding "!defined _STDIO_H"

#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H || !defined _STDIO_H

But of course that's not a fix because after compiling this single file i reverted gnulib/stdio.h back to normal

Petr Belyaev <upcfrost>
Fri 12 Sep 2014 01:45:57 AM UTC, comment #2: 

I have committed your fix to quit.h on the default branch:


And for completeness, your fix to gnulib was committed upstream at:


At some point we will update our copy of gnulib in Octave to incorporate this fix.

Thanks for your contribution!

Mike Miller <mtmiller>
Project Administrator
Thu 11 Sep 2014 05:12:42 AM UTC, comment #1: 

Thanks for your bug report. Your explanation makes sense to me, and fixing this doesn't look like it will have any effect on gcc builds so should be safe.

The first part of the patch looks ok to me. The second part of your patch cannot be applied, though, since it touches files that are part of gnulib. If you think there is a bug in gnulib's fcntl.in.h, you should report that to the gnulib project.

Are you ok with being credited for your changes as "Johannes Zarl <johannes.zarl@jku.at>"?

Mike Miller <mtmiller>
Project Administrator
Mon 08 Sep 2014 02:36:04 PM UTC, original submission:  

The file liboctave/cruft/misc/quit.h essentially includes stdio.h in the following fashion:

extern "C" {
#include <stdio.h>

Inside libgnu/stdio.h, there are definitions for getchar et. al. inside a namespace. All in all, the code amounts to something like the following:

extern "C" {
#include <stdio.h>
    namespace GNULIB_NAMESPACE
        int (*getchar) (void) = ::getchar;

This is ill-formed under the C++ standard section 7.5 (Paragraph 6), since under C linkage the namespace is to be ignored for the resulting symbol name.

g++ currently does not throw an error on this code, but icpc does.

Moving the include statements outside of the extern "C" linkage block fixes the issue.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #32053:  dont_mingle_extern_and_namespace.patch added by None (2KiB - application/octet-stream - This patch fixes all occurrences of the bug that I found.)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by upcfrost (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-09-12 mtmiller StatusNeed Info => Fixed
        Open/ClosedOpen => Closed
    2014-09-11 mtmiller Item GroupNone => Build Failure
        StatusNone => Need Info
    2014-09-10 None Attached File- => Added dont_mingle_extern_and_namespace.patch, #32053

    Back to the top

    Powered by Savane 3.7