Hi Ho! Sorry, if I sort of hijack this thread.
On Wed, 2009-04-29 at 15:43 +0000, Joseph S. Myers wrote: > > > "int i;" is not the same as "extern int i;". > > > > Sorry for my ignorance but I have been reading and searching for the > > answer and I cannot tell what is the difference between "int i = 1" > > and "extern int i = 1" at file-scope in C. > > I did not say those were different, I said the uninitialized case was > different, so "extern is implicit if missing" is not a general C rule. I think the difference between "int i;" and "extern int i;" at file-scope in C is that "int i;" will only be treated as a definition if it is not defined in another place in the same file/TU. IOW, its linkage is internal within the TU itself. But, "extern int i" is definitely treated as a declaration only that can later be defined either in the same TU or in another one. Is that true? Finally, is there any difference in declaring a non-inline function prototype with and without "extern" in C? That is, is there any difference between: extern int foo (int *bar); and int foo (int *bar); ? I think they are completely identical. Is that correct? Also, is there any difference in defining a non-inline function with and without "extern" in C? That is, is there any difference between: extern int foo (int *bar) { return *bar + 5; } and int foo (int *bar) { return *bar + 5; } ? I think they are also identical. Am I right? Who knows the one with "extern" can be overridden in another TU defining its own definition without "extern". Thank you for your help :-) > -- > Joseph S. Myers > jos...@codesourcery.com -- Best regards, Eus (FSF member #4445) In this digital era, where computing technology is pervasive, your freedom depends on the software controlling those computing devices. Join free software movement today! It is free as in freedom, not as in free beer! Join: http://www.fsf.org/jf?referrer=4445