[SAC-HELP] NetBSD falling foul of SAC's toupper/tolower macros

Kevin.Buckley at mcs.vuw.ac.nz Kevin.Buckley at mcs.vuw.ac.nz
Mon Sep 29 18:15:19 PDT 2008


Hi there,

I am sure this is a known issue but my searches turned up zilch
so, just in case ...

I came to build sac-101.2 on a NetBSD 4.99.58 platform with
gcc (GCC) 4.1.3 20080202 prerelease (NetBSD nb1 20070620), the
sac build being configured thus:

./configure --prefix=/local/scratch/kevin/sac-101.2

resulting in:

Compliation Options for sac (Seismic Analysis Code 101.2)

CFLAGS         =
LDFLAGS        =
LIBS           = -lm -lcurses
Debug          =
Optimization   =
Database       = off
Matlab         = off
X11-buffer     = on
X11-depth      = on
X_LIBS         =  -L/usr/pkg/lib
X_CFLAGS       =  -I/usr/pkg/include
Readline       = off
Editline       = on
Install Base   = /local/scratch/kevin/sac-101.2
System         =  (i386-unknown-netbsdelf4.99.58)


and saw this error:

gcc -DHAVE_CONFIG_H -I. -I. -I../inc        -I/usr/pkg/include -I../inc 
-I../libedit/include -c -o co/zgpmsg.o co/zgpmsg.c
In file included from /usr/pkg/include/readline/chardefs.h:26,
                 from /usr/pkg/include/readline/keymaps.h:36,
                 from /usr/pkg/include/readline/readline.h:38,
                 from co/zgpmsg.c:93:
/usr/include/ctype.h:71: error: expected identifier or '(' before 'int'
/usr/include/ctype.h:71: error: expected ')' before '?' token
/usr/include/ctype.h:72: error: expected identifier or '(' before 'int'
/usr/include/ctype.h:72: error: expected ')' before '?' token

this occurs because the toupper/tolower declarations in this system's
ctype.h

int     tolower(int);
int     toupper(int);

get mangled by the macro declaration in sac's

src/co/stdu.h

#ifndef CYGWIN
/*      macro expansions        */
#define tolower(c)       ((c>='A' && c<='Z') ? (c+('a'-'A')) : c)
#define toupper(c)       ((c>='a' && c<='z') ? (c-('a'-'A')) : c)
#endif /* CYGWIN */

as they are only protected by the CYGWIN define and so appear as:

int ((int>='A' && int<='Z') ? (int+('a'-'A')) : int);
int ((int>='a' && int<='z') ? (int-('a'-'A')) : int);


After removing the macro definitions, the code compiles OK.


-- 

Kevin M. Buckley                                  Room:  CO327
School of Mathematics, Statistics                 Phone: +64 4 463 5971
 and Computer Science
Victoria University of Wellington
New Zealand




More information about the sac-help mailing list