Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mit-eddie.UUCP Path: utzoo!linus!decvax!genrad!mit-eddie!gary From: gary@mit-eddie.UUCP (Gary Samad) Newsgroups: net.lang.c Subject: extern declaration inconsistency Message-ID: <1538@mit-eddie.UUCP> Date: Tue, 3-Apr-84 21:39:03 EST Article-I.D.: mit-eddi.1538 Posted: Tue Apr 3 21:39:03 1984 Date-Received: Thu, 5-Apr-84 03:21:16 EST Organization: MIT, Cambridge, MA Lines: 42 I spent hours debugging this--anyone know why it is a problem? Is it a 'feature' or is it a 'bug'? in file foo.c: char ch[32]; foo() { strcpy(ch,"string"); printf("&ch=%x\n",ch); } in file ref.c: extern char *ch; ref() { printf("&ch=%x\n",ch); printf(ch); } in file main.c: main() { foo(); ref(); } The program prints: &ch=2eb4 &ch=64abc Segmentation fault (core dumped) (The addresses are aproximately correct) The compiler didn't resolve the extern char correctly! Replacing the 'extern char *ch' with 'extern char ch[]' fixes it! Does anyone know why? By the way, this is with the 4.1BSD compiler running under Eunice. Gary Samad decvax!genrad!mit-eddie!gary