lkml.org 
[lkml]   [1998]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Declaring vars at first use
According to Matthias Urlichs:
> In dist.linux.kernel, article <908456202.25458@noris.de>,
> Chip Salzenberg <chip@perlsupport.com> writes:
> > Experience indicates otherwise. And consider how inconvenient it is
> > now to have two ifdef blocks -- one for the conditional code itself
> > and another at the top of the function for the variables that the code
> > needs. Bleh.
>
> Whatever happened to the idea of
> #ifdef FOOBAR
> {
> int foo_now, bar_later;
> [...]
> }
> #endif
> ?

That's great unless you have this:

#ifdef FOOBAR
int foo_var = foo_init();
#endif
...
#ifdef FOOBAR
foo_use(foo_var);
#endif
...
#ifdef FOOBAR
foo_use_again(foo_var);
#endif

The C++ approach also makes ifdef'ing existing code easier -- you often
don't have to introduce new scopes that the C approach would require.
--
Chip Salzenberg - a.k.a. - <chip@perlsupport.com>
"... under cover of afternoon in the biggest car in the county?!" //MST3K
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:45    [from the cache]
©2003-2011 Jasper Spaans