Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!ll-xn!ames!ucbcad!ucbvax!sdcsvax!hutch
From: hutch@sdcsvax.UCSD.EDU (Jim Hutchison)
Newsgroups: comp.sys.amiga,comp.lang.c
Subject: Please understand! (was Re: Beep Bug Fix For Dave Wecker's VT100 Program)
Message-ID: <2304@sdcsvax.UCSD.EDU>
Date: Sun, 14-Dec-86 12:09:09 EST
Article-I.D.: sdcsvax.2304
Posted: Sun Dec 14 12:09:09 1986
Date-Received: Tue, 16-Dec-86 02:57:41 EST
References: <1391@umd5>
Reply-To: hutch@sdcsvax.UUCP (Jim Hutchison)
Organization: UCSD EMU Project (Educational Microcomputer Unix)
Lines: 53
Keywords: proper,read,believe,extern
Xref: mnetor comp.sys.amiga:742 comp.lang.c:389

In article <1391@umd5> carl@umd5.umd.edu.UUCP (Carl Symborski) writes:
>/*
>
>Well all this talk about bugs in Dave Wecker's VT100 program which don't
>happen under MANX and do happen under LATTICE has got me started.  Darnit
>why dosn't the beep thing work when VT100 is compiled under LATTICE!
>...
#ifdef MODULE_MAIN
>...
>UBYTE Audio_AllocMap[4] = {1, 8, 2, 4};
>...
#else
>...
>extern UBYTE Audio_AllocMap[];
>...
>external array of type UBYTE.  We DON'T know how long it is, so when we say
>"sizeof(Audio_AllocMap)" we should expect zero maby one... but not four!!!!

Yes, a very nice trick.  It is typed as an array, and externed as an array.
If I say sizeof, the compiler can belch at me, or do the proper thing.  I can
not find what Lattice does as acceptable (silence is leaden :-).  The extern
here should say 4, or 0 and a warning that the compiler is not able to find
a size.

Why 0?  Because if you can't get the right size, and the user to too lazy to
make up for it, you should not introduce cryptic bugs!!!

Here is what the 4.3bsd compiler from berkeley says:
t1.c:	/* containing the declaration */
t2.c:	/* containing the extern      */
"t2.c", line 8: warning: sizeof returns 0

t1.c>
char string[13] = "Hi I am Jim.";
		/* 123456789-123 */
main()
{
	write(1,string,sizeof(string));
	second();
}
t2.c>
extern char string[];

second()
{
	write(1,string,sizeof(string));
}
<>

-- 
    Jim Hutchison   		UUCP:	{dcdwest,ucbvax}!sdcsvax!hutch
		    		ARPA:	Hutch@sdcsvax.ucsd.edu
Fig is a 5 stage concept.