From owner-freebsd-chat Mon Dec 7 20:20:50 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA06792 for freebsd-chat-outgoing; Mon, 7 Dec 1998 20:20:50 -0800 (PST) (envelope-from owner-freebsd-chat@FreeBSD.ORG) Received: from quackerjack.cc.vt.edu (quackerjack.cc.vt.edu [198.82.160.250]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id UAA06786 for ; Mon, 7 Dec 1998 20:20:47 -0800 (PST) (envelope-from jobaldwi@vt.edu) Received: from sable.cc.vt.edu (sable.cc.vt.edu [128.173.16.30]) by quackerjack.cc.vt.edu (8.8.8/8.8.8) with ESMTP id XAA18623 for ; Mon, 7 Dec 1998 23:20:43 -0500 (EST) Received: from john.baldwinfamily.org (jobaldwi.campus.vt.edu [198.82.67.63]) by sable.cc.vt.edu (8.8.8/8.8.8) with ESMTP id XAA01459 for ; Mon, 7 Dec 1998 23:20:42 -0500 (EST) Message-ID: X-Mailer: XFMail 1.3 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Mon, 07 Dec 1998 23:20:41 -0500 (EST) Reply-To: jobaldwi@vt.edu Organization: Virginia Tech From: John Baldwin To: freebsd-chat@FreeBSD.ORG Subject: gcc and dup variables... Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org -----BEGIN PGP SIGNED MESSAGE----- I just ran into a rather weird little oddity. I'm working on a C project, and in one module, I have a private variable declared as so: FILE *dbaseFile; In another module, I have a private variable as such: char *dbaseFile; It seems that ld has merged these two references into the same thing, with some rather interesting side effects when I tried to print the string out after opening the file. I would've thought that I would have gotten a linker error for duplicate symbols of conflicting types, but I guess that ld treats all pointers the same as it doesn't know types? But, I also thought that if two modules both had non-external vars of the same name ld should've flagged that instead of silently merging the two. So a) is this how ld is supposed to work and b) if so, why? I can see how if one was two lazy to declare variables extern everywhere but once that this would be helpful, but I'd rather ld give me a link error as it can lead to some interesting bugs. - --- John Baldwin -- http://members.freedomnet.com/~jbaldwin/ PGP Key: http://members.freedomnet.com/~jbaldwin/pgpkey.asc Nothing is so permanent as a temporary government program. -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQB1AwUBNmypD4jYza302vYpAQF4ngL7BccapofLYJ5Xze8An2VsiMKl+Z+0iTOD Tr1Nw0FR7y5smWdyw2U+r+FIb5cEd27KDoFPQcKdyA+O3l1daOsnkJqCHemgkhKl hbdPqDGEQLCBwHCg4n2o2U0/ocz9B/nk =Qn+5 -----END PGP SIGNATURE----- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message