[GTALUG] Ubuntu 16.04 / gcc 5.4.0 - errors generated inside system include files

D. Hugh Redelmeier hugh at mimosa.com
Sun Aug 7 03:32:25 EDT 2016


| From: Stewart C. Russell via talk <talk at gtalug.org>

[Sorry, I've ascii-fied GCC's UNICODE diagnostics since I'm still in the 
1980s.]

| I'm hitting unexpected problems building some old-ish code (UCB Logo 6,
| after hearing Seymour Papert went PENUP last week). gcc seems to be
| choking on its own header file, mathcalls.h:

Sad about Papert.

UCB Logo, last I looked, wasn't really maintained any longer.  It was
last updated in 2008.  But it seems to still work.  Brian Harvey, the
author, is an interesting guy too.  He wrote a series of Logo books
published by MIT press.

| gcc -g -O   -O0 -DUSE_OLD_TTY   -c -o coms.o coms.c
| In file included from coms.c:30:0:
| /usr/include/x86_64-linux-gnu/bits/mathcalls.h:100:1: error: expected
| `=', `,', `;', `asm' or `__attribute__' before `extern'
|  __MATHCALL_VEC (exp,, (_Mdouble_ __x));
|  ^
| /usr/include/x86_64-linux-gnu/bits/mathcalls.h:100:1: error: expected
| `=', `,', `;', `asm' or `__attribute__' before `extern'
|  __MATHCALL_VEC (exp,, (_Mdouble_ __x));
|  ^
| /usr/include/x86_64-linux-gnu/bits/mathcalls.h:100:1: error: expected
| `=', `,', `;', `asm' or `__attribute__' before `extern'
|  __MATHCALL_VEC (exp,, (_Mdouble_ __x));
|  ^

Odd that you got three identical error messages.  They look like they
are out of the C parser.  It is saying that this token isn't expected
before "extern".  But I don't see extern as the next token.  So I'm
not sure.

__MATHCALL_VEC is supposed to be a C preprocessor macro.  One that
does tricky C preprocessor operations.  With the leading __, it is in
the namespace reserved for the system (i.e. glib)

UCB Logo surely makes no (direct?) use of any SIMD instructions (the
point of __MATHCALL_VEC).

If you look at the -E output, has __MATHCALL_VEC been replaced or is
it still there?

- if it is replaced, what's the resulting pure C declaration look like?

- if it isn't replaced, the problem is that the macro definition is
  somehow missing in the compilation process.

| (this on Ubuntu 16.04, gcc 5.4.0, x86_64)

Good to know.

| I can build other code that includes math.h, the source of the
| mathcalls.h inclusion. The package builds fine on a Raspberry Pi
| (Raspbian, gcc 4.9.2, armv7l). The package even built on x86_64 under
| Ubuntu 15.10.
| 
| Is this just Canonical mucking about with the compiler settings again?

Dunno.

As an experiment, I compiled a file that contained only an include of
math.h on an AMD64 Ubuntu 16.04 LTS (I happened to update our kitchen
computer, an ancient Atom-based system to 16.04 earlier today).

There was no error message.

So the problem is probably interference between headers or compilation
flags and the header.

What comes before the include of math.h?  What flags are used?

You could copy the file and then iteratively pare it down until the
error goes away.  (Also: pare down the gcc flags.)

Looking around line 30 of coms.c, I see:

	#ifdef HAVE_WX
	#define fgets wx_fgets
	extern int check_wx_stop(int force_yield);
	#endif

	#define WANT_EVAL_REGS 1
	#include "logo.h"
	#include "globals.h"
	#include <math.h>

The only suspicious thing is that there are two headers included
before math.h.  Try permuting these includes to see if that makes a
difference.

As a general rule, it is good to include system headers before program
headers because then you know that the system header isn't being
interfered with.  Of course sometimes you wish to interfere with a
system header, but that has dangers.

The header logo.h is meant to make the code portable.  That sometime
causes problems as systems evolve.  Remember THINK_C (for 68k-based
Macs)?  Or __TURBOC__ (Borland)?  Or __ZTC__ (Zortech C)?

I maintain Jove, a portable C program written in the early 1980s.
Once in a while, names that are in the programmer's namespace get
co-opted by some system.  Maybe that is what has happened.

I just noticed that I exchanged email with Brian Harvey about UCB Logo
last year.  I think he uses or has used Jove as his editor -- UCB Logo
knows about it.  I thought I found documentation bugs about this in
UCB Logo but he didn't think so.  It seems that on Unix, UCB Logo
defaults to emacs, not jove, contrary to the documentation.

Fedora has a package "ucblogo" (which has an emacs dependency, dammit).
Ubuntu 14.04 also has a ucblogo package.  I didn't try 16.04.


More information about the talk mailing list