Date: Mon, 07 Dec 1998 23:20:41 -0500 (EST) From: John Baldwin <jobaldwi@vt.edu> To: freebsd-chat@FreeBSD.ORG Subject: gcc and dup variables... Message-ID: <XFMail.981207232041.jobaldwi@vt.edu>
next in thread | raw e-mail | index | archive | help
-----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 <jobaldwi@vt.edu> -- 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.981207232041.jobaldwi>