C
CBFalconer
Roland said:. snip ...
Why are the functions static? That's only confusing for a newbie.
Because they are not used outside that module. This avoids name
space pollution. Routine.
Roland said:. snip ...
Why are the functions static? That's only confusing for a newbie.
jacob navia said:Well, EBCDIC was a 7 bit code, used for punched cards. The eighth bit
was there to signal the card reader that a character was in that column.
Using only 7 bits, the codes are continuous.
Using only 7 bits, the codes are continuous.
jacob said:[...]
I believe goto is not bad when used correctly. It is part of the
language anyway, and if used correctly it is perfectly OK.
Richard Heathfield said:Keith Thompson said:Richard Heathfield said:jacob navia said:
I have written this small parser to print out the functions defined in a
C file. This is an example of parsing in C, that I want to add to my
tutorial. Comments (and bug reports) are welcome.
foo.c:12: parse error before `/'
foo.c:17: stray '\' in program [51 lines deleted]
make: *** [foo.o] Error 1
Every one of those errors is caused by two things: "//" comments and
mixed declarations and statements.
<shrug> I figured it had to be something like that. So - does anyone have a
conforming C99 compiler that we can use to test Mr Navia's code? No? Oh
well.
Er, so what? Despite the misleading switch-name, gcc is not a C99-conforming
compiler.
jacob navia said:[snip][...]
Mmmm, it *could* be, but I have never found a machine where they aren't
contiguous...
That doesn't mean such machines don't exist. I've spent several
years working on such machines. Look up "EBCDIC" in Google.
Well, EBCDIC was a 7 bit code, used for punched cards. The eighth bit
was there to signal the card reader that a character was in that column.
Using only 7 bits, the codes are continuous. When punched cards weren't
so much used (approx beginning of the 80es) IBM added foreign language
characters in those positions.
Why are the functions static? That's only confusing for a newbie.
Hmm, goto in a C tutorial? You could add an exercise for the reader:
'Enhance the clarity of this function by rewriting it with one return
statement and without using goto'.
This has a maybe anectodical importance, but its practical impact is ...
Keith Thompson said:
<shrug> I figured it had to be something like that. So - does anyone have a
conforming C99 compiler that we can use to test Mr Navia's code? No? Oh
well.
Er, so what? Despite the misleading switch-name, gcc is not a C99-conforming
compiler.
Don't be childish. It ill becomes you.
Did you spot something in Jacob's code that was not C99-conforming?
Richard said:Mark McIntyre said:
Hmm? Does that mean you /do/ have a C99 conforming compiler? Fabulous - let
us know how it goes.
No. Did you spot something in the code that *needed* a C99 feature, a
feature so vital that it justified making the code non-C90-conforming?
<snip>
You change your arguments heathfield.
First you tell there isn't any c99 compiler,
then you argue that c99 is not needed.
There is nothing in the code that needs to be c90 either. I could have
written it in K&R C, without prototypes syntax.
But I am not in a nostalgia trip,
I believe C evolves and I like it like that.
Can't you contribute anything substantial to the discussion?
Just empty polemic?
So far there is nothing in your arguments worth mentioning...
What about the algorithm? You see any flaws in there?
P.S. And please do not start with EBCDIC, I changed that to use
isalpha() ...
Oh no, the sky is falling, someone has posted code using some C99 features.Richard said:Keith Thompson said:
That, in my view, is the author's job, not yours or mine. (And it shows that
the C99isms have been adopted gratuitously, presumably to make the code
less portable. Why anyone should wish to do this is beyond me.)
Oh no, the sky is falling,
someone has posted code using some C99 features.
Ian Collins said:Oh no, the sky is falling, someone has posted code using some C99 features.
Richard Heathfield said:Ian Collins said:
Yes, it's in free fall, just like the rest of the planet. If this bothers
you, find a planet with less atmosphere.
...which is fine, as long as they don't expect anyone else to be able to
compile it on a conforming implementation.
Look, if there were some compelling reason for using C99 features, okay,
fair enough: "sorry for leaving Richard H (and most of the conforming
world) behind but these C99 features are just too useful to ignore, and if
that means a portability loss, so be it". But that does not appear to be
the case here.
This is not about C90 vs C99. This is about "works everywhere" vs "works
almost nowhere, unless you use a non-conforming compiler".
With yes, relative to, only when Jacob posts C99Richard said:Ian Collins said:
Yes, it's in free fall, just like the rest of the planet. If this bothers
you, find a planet with less atmosphere.![]()
Which will never happen with C99 unless people (want to) use it.....which is fine, as long as they don't expect anyone else to be able to
compile it on a conforming implementation.
Look, if there were some compelling reason for using C99 features, okay,
fair enough: "sorry for leaving Richard H (and most of the conforming
world) behind but these C99 features are just too useful to ignore, and if
that means a portability loss, so be it". But that does not appear to be
the case here.
This is not about C90 vs C99. This is about "works everywhere" vs "works
almost nowhere, unless you use a non-conforming compiler".
But since gcc supports a subset, and a useful subset, its hardly "almost
nowhere" is it?
Richard Heathfield said:Richard said:
When I invoke my gcc implementation in conforming mode, it (correctly)
diagnoses single-line comments, mixed code/decls, etc. If you are asking me
to turn off conforming mode, the answer is "No".
I thought your original repose was a little melodramatic, considering
C99 is (a) standard C, the topic of this group.
Which will never happen with C99 unless people (want to) use it.
Admittedly I'm biased, my platform's (POSIX) APIs use C99 features and
my stuff tends to be platform specific.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.