On 14/10/11 10:27 AM, Pontus Pihlgren wrote:
On Fri, Oct 14, 2011 at 08:56:44AM -0400, Toby Thain
wrote:
Here is
another one which also requires some knowledge of standards:
The example *above* doesn't require reading any standards; it's
basic C usage and is in K&R 1. It would be hard to read or write C
in any serious way without having internalised things like this.
(Because both constructs are common.)
You might be right and I just haven't coded enough C to have
internalised that thing.
An oft-quoted C idiom (the cuteness of which does wear off a bit) was
exhibited - apart from in Unix sources - in the K&R book. To understand
it one might have to realise that adding a constant to a pointer, and
dereferencing, is equivalent to p[constant]:
mystery(char *s, char *t) {
while(*s++ = *t++)
;
}
The *(p+c) business cannot remain mysterious if one wants to write
idiomatic C. I would tend to prefer the idiom above to a tedious loop
with counter and []'s written longhand, though a comment might be warranted.
--Toby
What is
the safe thing to do after a longjmp to a previous setjmp
position?
iirc, you would avoid using any auto (stack) variables that were in scope.
Yes, so what is left to do?
/P