Article View: comp.lang.c.moderated
Article #2218Re: "extern" and function declarations
From: Larry Jones
Date: Fri, 08 Mar 1996 23:10
Date: Fri, 08 Mar 1996 23:10
19 lines
1364 bytes
1364 bytes
In article <4hmslm$b3l@solutions.solon.com>, Guillaume Laurent <glaurent@nissart.lagaude.ibm.com> writes: | I've got a question here : what if the same above declaration is made | in two (or more) files, compiled seperately then linked together ? | | ie, in file a.c : extern int i = 1; | and in file b.c : extern int i = 2; | | If I understand correctly what you've said, both of these declarations | will reserve space, and give i a value. My question is, what decides | which value will actually be "used", and what happens to the "duplicate" | space ? It's undefined. In some implementations the first one the linker sees wins, in other implementations the last one the linker sees wins, and in still other implementations you get an error. ---- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070 larry.jones@sdrc.com Girls are so weird. -- Calvin
Technical Details
Message-ID:
<4hqeog$1rn@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4hdqjq$8pr@solutions.solon.com> <4hmslm$b3l@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: larry.jones@sdrc.com (Larry Jones) Newsgroups: comp.lang.c.moderated Subject: Re: "extern" and function declarations Date: 8 Mar 1996 17:10:08 -0600 Organization: SDRC Engineering Services Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4hqeog$1rn@solutions.solon.com> References: <4hdqjq$8pr@solutions.solon.com> <4hmslm$b3l@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com