Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!vmucnam!imag!inria!axis!alastair From: alastair@axis.UUCP (Alastair Adamson) Newsgroups: net.lang.c Subject: Re: Proper use of "extern" ... Message-ID: <712@axis.UUCP> Date: Mon, 9-Jun-86 11:56:06 EDT Article-I.D.: axis.712 Posted: Mon Jun 9 11:56:06 1986 Date-Received: Sat, 14-Jun-86 05:55:22 EDT References: <223@comp.lancs.ac.uk> Reply-To: alastair@axis.UUCP (Alastair Adamson) Organization: Axis Digital, 135 rue d'Aguesseau, Boulogne, 92100, FRANCE Lines: 29 Keywords: extern,static [feed this line to the Orcs] In article <223@comp.lancs.ac.uk> david@comp.lancs.ac.uk (David Coffield) writes: >Suggestions, please, as to the correct use of "extern" .. >At the top of this file do we put >a) static void g() or >b) extern void g()? (extern static must be meaningless). I would always prefer a) since it helps the reader by making explicit the fact that the function is local to this file. Further, I like to declare all extern (other file, library) functions and static functions before the definition of the first function in a file, after any #includes, #defines and global variables, as in: #include lines #define lines global variables (definitions) extern globals (declarations) static functions (declarations) extern functions (declarations) function definitions Thus, I would also have said "static void f()" before f()'s definition. There is a problem with static functions, namely that some C compilers don't know how to handle them and generate illegal instructions so that the assembler stage bombs out. You may say that one should avoid such ridiculous compilers and I would agree with you. Unfortunately, however, when porting software to other computers one has to put up with what's available!