Re: [dev] Local vs global variables

From: Anders Andersson <>
Date: Fri, 6 Nov 2009 19:43:24 +0100

On Fri, Nov 6, 2009 at 6:34 PM, QUINTIN Guillaume
<> wrote:
> Hi all,
> Someone just told me that, when writing C code, one should NOT use ANY
> global variables. He did not tell me to use global variables as few as
> possible, he did tell me to use ABSOLUTELY NO global variables in any
> kind of C code (single program, library, OS kernel, any kind there is
> ...)
> What do you think about that ?

Well, it's a stupid thing to say without explaining WHY. There are a
number of reasons why not to use 'global variables', some from point
of view of efficiency (code optimization) and some from a
maintainability view. When you've written your fair share of C code,
this is something you learn, sometimes the hard way. (Oops, did I use
that variable name in both these routines, that I now want to use in
the same project?)

Still, like the venerable goto, sometimes, not often, it's the best
tool at hand.

// pipe
Received on Fri Nov 06 2009 - 18:43:24 UTC

This archive was generated by hypermail 2.2.0 : Fri Nov 06 2009 - 18:48:02 UTC