Article View: comp.std.c
Article #5001Re: Initializing a variable in terms of itself
From: J. Kanze
Date: Tue, 09 Apr 1996 10:59
Date: Tue, 09 Apr 1996 10:59
44 lines
1796 bytes
1796 bytes
In article <4k65h6$dfe@nntp.crl.com> tmcd@crl.com (Timothy A. McDaniel)
writes:
|> In article <KANZE.96Apr2171323@slsvgqt.lts.sel.alcatel.de>,
|> James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> wrote:
|> >In article <4jpj9l$ik9@cnn.Princeton.EDU> tim@franck (Tim Hollebeek)
|> >writes:
|> ...
|> >|> int x = x;
|> ...
|> >The reference to `x' in the initialization expression is not, per se,
|> >illegal. The variable is declared, and available for use, as soon as
|> >the compiler sees the `=' sign.
|> So
|> void *x = &x;
|> would be legal,
Exactly.
|> then, and x would point to itself? (Or would it have
|> to be
|> void *x = (void *) &x;
|> ?)
The cast is not necessary.
I've even used this sort of thing in the past:
struct NODE
{
NODE* next ;
NODE* prec ;
} ;
struct NODE root = { &root , &root } ;
Note that despite the added braces, etc., this is really just a variant
of the same theme.
--
James Kanze (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle --
-- Beratung in industrieller Datenverarbeitung
Technical Details
Message-ID:
<KANZE.96Apr9125938@gabi.gabi-soft.fr>Path:
arc1-ca.pugleaf.net!gabi-soft.fr!usenetReferences:
<4jpj9l$ik9@cnn.Princeton.EDU> <KANZE.96Apr2171323@slsvgqt.lts.sel.alcatel.de> <4k65h6$dfe@nntp.crl.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!gabi-soft.fr!usenet
From: kanze@gabi-soft.fr (J. Kanze)
Newsgroups: comp.std.c
Subject: Re: Initializing a variable in terms of itself
Date: 09 Apr 1996 10:59:38 GMT
Organization: GABI Software, Sarl.
Message-ID: <KANZE.96Apr9125938@gabi.gabi-soft.fr>
References: <4jpj9l$ik9@cnn.Princeton.EDU> <KANZE.96Apr2171323@slsvgqt.lts.sel.alcatel.de>
<4k65h6$dfe@nntp.crl.com>
NNTP-Posting-Host: gabi.gabi-soft.fr
In-reply-to: tmcd@crl.com's message of 6 Apr 1996 16:18:46 GMT