On Sep 20, 2005, Stephen Pollei <[email protected]> wrote:
> On 9/19/05, Horst von Brand <[email protected]> wrote:
>> Nikita Danilov <[email protected]> wrote:
>> > It's other way around: declaration is guarded by the preprocessor
>> > conditional so that nobody accidentally use znode_is_loaded() outside of
>> > the debugging mode.
>>
>> Since when has a missing declaration prevented anyone calling a function in
>> C?!
> Never AFAIK... K&R, ANSI,ISO C89, c99, whatever version that I know of...
Actually... C99 requires a declaration (not necessarily with a
prototype) before a function can be called. A prior declaration is
required for all identifiers. I'm not sure whether this is new in C99
or carried over from ISO C90 (AKA ANSI C89). The fact that so many
compilers accept calls without prior declarations is a common
extension to the language, mainly for backward compatibility.
> It's really over silly anyway, as it will fail at link time if they
> had matching preprocessor stuff around the function definition.
Not really. A compiler might optimize away the reference to the
symbol if it's say guarded by a condition whose value can be
determined to be false at compile time. If you rely on that, moving
to a different compiler that is unable to compute the condition value,
or simply is pickier as to standard compliance, will get you errors.
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
|
|