Re: [PATCH 5/9] bfs: move function prototype to the proper header file

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Kyle Moffett
Date: Thursday, January 24, 2008 - 6:55 pm

On Jan 24, 2008, at 18:13, Dmitri Vorobiev wrote:


The "extern" keyword on functions is *completely* redundant.

For C variables:
   Declaration:  extern int foo;
   Definition:   int foo;
   File-scoped:  static int foo;

For C functions:
   Declaration:  void foo(int x);
   Definition:   void foo(int x) { /*...body...*/ }
   File-scoped:  static void foo(int x) { /*...body...*/ }

The compiler will *allow* you to use "extern" on the function  
prototype, but the presence or absence of a function body is  
sufficiently obvious for it to determine whether the prototype is a  
declaration or a definition that the "extern" keyword is not required  
and therefore redundant.

For maximum readability and cleanliness I recommend that you leave off  
the "extern" on the function declarations; it makes the lines much  
longer without obvious gain.

Cheers,
Kyle Moffett


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/9] bfs: assorted cleanups, Dmitri Vorobiev, (Thu Jan 24, 3:31 pm)
[PATCH 1/9] bfs: remove a useless variable, Dmitri Vorobiev, (Thu Jan 24, 3:32 pm)
[PATCH 2/9] bfs: coding style cleanup in fs/bfs/inode.c, Dmitri Vorobiev, (Thu Jan 24, 3:32 pm)
[PATCH 3/9] bfs: coding style cleanup in fs/bfs/bfs.h, Dmitri Vorobiev, (Thu Jan 24, 3:32 pm)
[PATCH 4/9] bfs: coding style cleanup in fs/bfs/dir.c, Dmitri Vorobiev, (Thu Jan 24, 3:32 pm)
[PATCH 6/9] bfs: coding style cleanup in fs/bfs/file.c, Dmitri Vorobiev, (Thu Jan 24, 3:32 pm)
[PATCH 8/9] bfs: remove multiple assignments, Dmitri Vorobiev, (Thu Jan 24, 3:32 pm)
[PATCH 9/9] bfs: use the proper header file for inclusion, Dmitri Vorobiev, (Thu Jan 24, 3:32 pm)
Re: [PATCH 5/9] bfs: move function prototype to the proper ..., Kyle Moffett, (Thu Jan 24, 6:55 pm)
Re: [PATCH 0/9] bfs: assorted cleanups, Dmitri Vorobiev, (Fri Jan 25, 3:25 am)