Subject: egcs quirk
To: None <tech-toolchain@NetBSD.ORG>
From: Hauke Fath <hauke@Espresso.Rhein-Neckar.DE>
List: tech-toolchain
Date: 05/24/1998 12:26:29
Hi,

while using egcs built from -current sources on the following code I
see...


[...]

/* 
 * Table of supported disk types.
 * The table order seems to be pretty standardized across NetBSD ports, but
 * then, they are all MFM... So we roll our own for now.
 */
static fdInfo_t fdTypes[] = {
	{ 1, 80, 512, 10, 10,  800, 12, 2, kGCR, "400K Sony" },
	{ 2, 80, 512, 10, 20, 1600, 12, 2, kGCR, "800K Sony" }
};

[...]

/*
 * fdDeviceToType
 *
 * maps the minor device number (elsewhere: partition type) to
 * a corresponding disk format.
 * This is currently: 
 * 	fdXa	default (800K GCR)
 *	fdXb	400K GCR
 *	fdXc	800K GCR
 */
static fdInfo_t *
fdDeviceToType(	fd_softc_t	*fd,
		dev_t		dev)
{
	int		type;
	fdInfo_t	*thisInfo;
	extern fdInfo_t	fdTypes[];	/* XXX */

	type = minor( dev) % MAXPARTITIONS;	/* 1,2,...		*/

	if( type > sizeof(fdTypes) / sizeof(fdTypes[0]) )	<-- Line 1552
		thisInfo = NULL;
	else
		thisInfo = (type == 0) ? fd->defaultType : &fdTypes[type-1];

	return( thisInfo);
}


[hauke@q700] ~/<4>lkm/iwm > make
rm -f machine &&  ln -s ../../../../arch/mac68k/include machine
rm -f m68k &&  ln -s ../../../../arch/m68k/include m68k
cc -Wall -Wstrict-prototypes -Wmissing-prototypes  -Wno-uninitialized -Wno-unused -g -O -m68030  -D_KERNEL -D_LKM -I. -I/u/hauke/work/sys/arch/mac68k/lkm/iwm -I../../../.. -I../../../../arch -Werror -DDIAGNOSTIC -DDDB -DDEBUG -nostdinc -Dmc68020 -Dmac68k -c fd.c
fd.c: In function `fdDeviceToType':
fd.c:1552: sizeof applied to an incomplete type
*** Error code 1

Stop.
[hauke@q700] ~/<4>lkm/iwm > 


The "error" goes away if I drop the "extern" declaration. Now I am no
longer as sure in C as I used to be (have seen too much Java code in
the last year), but this has built cleanly for two years with the
2.7.2.x gcc.

"Bug or feature"?

	hauke


-- 
"If the designers of X built cars, there would be no fewer than five 
steering wheels hidden about the cockpit, none of which follow the same 
principles - but you'd be able to shift gears with your car stereo.  
Useful feature, that."    (js@cs.vu.nl in de.talk.sex)