Re: using "!!" in "c"
- From: "pemo" <usenetmeister@xxxxxxxxx>
- Date: Thu, 19 Jan 2006 16:02:53 -0000
<snip>
>> So is (value, 0) (i.e., a comma operator). It turns a scalar value
>> into 1 or 0. It just happens to be 0.
>
> What's the point here?
>I believe that Keith was just pointing out that your specification of
what !! does was incomplete. What he wrote met your specification but
would generally be pointless in real code (there are potentially some
exceptions) and does not do what !! does.
If that *IS* the case, it seems um, rather unnecessarily pedantic - I
believe that what I said was clear enough - and corrrect in as far as it
went: and I also didn't say it was the only way to do something .... so why
point out alternatives? Maybe it's necessary to produce litanies containing
alternative possibilities for each non-exhaustive statement ever made here
sometimes?
>>> printf("%p\n", (void *)"boo");
>>>
>>> will output some value that's not 0, and very unlikely to be 1, e.g.,
>>> 0040300
>
>> It will output some implementation-specific sequence of printing
>> characters. The sequence may or may not look like a number.
>
> Can you explain this comment too? Is it an allusion to some obscure
> minutiae in the std, like "In reality, an implementation is free to encode
> an address such that it is displayed in egyptian hieroglyphics"?
>One very common format of output is something like "1234:5678", another
is something like "0x12345678". <snip>
Ah, so it was as I expected - an allusion to some obscure minutiae [well, it
is isn't it - letter-of-the-law-correct-or-not] that seems picky and
generally non-constructive. The two examples you gave look like numbers to
me. And I would hazard a guess that most every compiler outputs something
similar - even if it doesn't *have to*. So, saying that a compiler *could*
output this in a braille encoding of the morse-code interpretation of
egyptian hieroglyphics is kinda like saying that there is a remote
possibility that you *could* pick up a book which is written in English -
but that you can't read - because the author decided to choose a remote
vocabulary and to 'encode' his/her prose in such an impenetrable way as it
make it more or less impossible. Both situations *could* exist, but both
are, in reality, unlikely to - so what's the point in making a noise about
it?
>> Interesting, so something like this is basically illegal/non-portable
>> now?
>>
>> void (* n)(void) = (void(*)(void))42;
>>
>> n();
>>
>> Years ago I used to use something like the above for invoking interrupt
>> routines.
> What you show the above has *always* been non-portable.
Yes [I know!], my V.POOR wording - the question ought to have been ... is
the code illegal, without going through the unsigned char * route?
.
- Follow-Ups:
- Re: using "!!" in "c"
- From: Keith Thompson
- Re: using "!!" in "c"
- From: Flash Gordon
- Re: using "!!" in "c"
- References:
- using "!!" in "c"
- From: markryde
- Re: using "!!" in "c"
- From: pemo
- Re: using "!!" in "c"
- From: Keith Thompson
- Re: using "!!" in "c"
- From: pemo
- Re: using "!!" in "c"
- From: Flash Gordon
- using "!!" in "c"
- Prev by Date: Re: c program binary/image in memory
- Next by Date: Re: c program binary/image in memory
- Previous by thread: Re: using "!!" in "c"
- Next by thread: Re: using "!!" in "c"
- Index(es):