Re: [dev] Local vs global variables

From: Szabolcs Nagy <nszabolcs_AT_gmail.com>
Date: Sat, 7 Nov 2009 16:17:29 +0200

On 11/6/09, Anselm R Garbe <anselm_AT_garbe.us> wrote:
> 2009/11/6 QUINTIN Guillaume <coincoin169g_AT_gmail.com>:
>> 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
>
> Is he sure he never uses global variables? What about our old friend errno?
>

better examples are stdin, stdout and stderr which are global pointers
to mutable global objects and one usually uses them

there are several functions in the standard that depend on global
mutable state eg malloc, rand, atexit, setjmp, setenv, fesetenv,
strtok, setlocale+functions with locale specific behaviour (one of the
ugliest part of the c99 standard) and of course many function sets
errno
Received on Sat Nov 07 2009 - 14:17:29 UTC

This archive was generated by hypermail 2.2.0 : Sat Nov 07 2009 - 14:24:02 UTC