delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/04/21/18:53:04

From: duperval AT ERE DOT UMontreal DOT CA (Duperval Laurent)
Subject: Pre-processor bug (?)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Tue, 21 Apr 92 18:31:50 EDT
Status: O

With the following definitions,

typedef signed char	schar;
typedef unsigned char	uchar;
typedef schar	xchar;
typedef	xchar	boolean;	   	/* 0 or 1 */

# define CHAR_P char
# define SCHAR_P schar
# define UCHAR_P uchar
# define XCHAR_P xchar
# define BOOLEAN_P boolean

#define E extern

E char FDECL(lowc, (CHAR_P));
E int FDECL(xytod, (SCHAR_P,SCHAR_P));
E int FDECL(movecmd, (CHAR_P));
E int FDECL(getdir, (BOOLEAN_P));

and the following function declarations,

char
lowc(sym)
char sym;

int
xytod(x, y)	/* convert an x,y pair into a direction code */
schar x, y;

int
movecmd(sym)	/* also sets u.dz, but returns false for <> */
char sym;

int
getdir(s)
boolean s;

I get the following errors:

cmd.c: In function `lowc':
cmd.c:819: argument `sym' doesn't match function prototype
cmd.c:819: a formal parameter type that promotes to `int'
cmd.c:819: can match only `int' in the prototype
cmd.c: In function `xytod':
cmd.c:834: argument `x' doesn't match function prototype
cmd.c:834: a formal parameter type that promotes to `int'
cmd.c:834: can match only `int' in the prototype
cmd.c:834: argument `y' doesn't match function prototype
cmd.c:834: a formal parameter type that promotes to `int'
cmd.c:834: can match only `int' in the prototype
cmd.c: In function `movecmd':
cmd.c:857: argument `sym' doesn't match function prototype
cmd.c:857: a formal parameter type that promotes to `int'
cmd.c:857: can match only `int' in the prototype
cmd.c: In function `getdir':
cmd.c:878: argument `s' doesn't match function prototype
cmd.c:878: a formal parameter type that promotes to `int'
cmd.c:878: can match only `int' in the prototype


The only way I have found, so far, to correct the problem is to rewrite
the definitions and the headers as standard C, i.e:

int movecmd(char);
int movecmd(char c)
{
	function body
}

The same code compiles under BC++ 2.0 but not under DJGPP 1.06.  Exactly
what is wrong?
--
Laurent Duperval
duperval AT ere DOT umontreal DOT ca
duperval AT jsp DOT umontreal DOT ca

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019