A
Al Balmer
Richard Heathfield posted:
A "fortnight" is exactly two weeks where I'm from.
Yes, but how long is the "last minute"?
Richard Heathfield posted:
A "fortnight" is exactly two weeks where I'm from.
Oh! You were so close. You meant to say: "Of course it does". I
personally endorse the inclusion of pop-count operations in the C
standard library as well. Also bit scanning instructions. Following
the impeccable reasoning you just presented.
Stephen Sprunk said:At a minimum, C headers should be digestible by a C++ compiler (with
extern "C" {...} wrapped around them) so that C++ programs can link
with C libraries. This greatly expands the number of people that can
use your code and costs virtually nothing.
As far as the internals in the .c file, I wouldn't say anyone goes to
pains to make the code into the common subset of C and C++, but one
shouldn't go out of their way to make code uncompilable as C++
(e.g. using new or class as identifiers). This is one reason you see
a lot of casts in "C" code that aren't needed -- someone put them in
so they could compile as C++ too.
pete said:But now that you mention it,
the text of C89 looks to be about the same
as the footnotes of C99.
Yep -- C99 is 12 point body with 10 point footnotes, C89 was 10 point body
with (I think) 9 point footnotes. If I ever produce another official
copy of the standard, I'm inclined to go back to the smaller type.
Keith Thompson <kst- said:Perhaps the C99 standard uses larger print because we were all 10
years older in 1999 than in 1989. }
Keith Thompson said:I suspect a lot of casts in C code are there because the author didn't
know they were unnecessary.
I might be tempted to use new or class as an identifier deliberately.
If nothing else, it would serve as a flag to indicate that the code
has never been tested as C++, and if you feel the need to compile it
as C++ for some reason it's going to take a bit of work. And of
course *any* C code I write using malloc() will almost certainly not
be valid C++ ("almost" because I might happent to assign the result to
a void*).
Stephen Sprunk said:Other than the need for more casts, I fail to see why code using
malloc() would be less viable under C++. malloc() et al work just
fine in C++ as long as you don't try to mix in use of new/delete or
try to malloc() a class with {con,de}structors.
Keith said:Keith said:(e-mail address removed) writes: [...]
and 2) Non-determinable integer scalar sizes, that are not
enforced to 2s complement.
I.e., the standard can be implemented on architectures that don't use
2's complement.
Right; and there was a time where this might have made sense. It was
certainly long before 1999.
*I* as a programmer can will never ever be in a position to test the
validity of code on a non-2s complement machine. I can't realistically
buy such a machine. I can't gain access to one, and I don't personally
know of anyone who has access to such a machine. And 99.999% of all
programmers are in the same position. Cryptographers have decided they
don't know how to deal with those 0.001% and so they just push on ahead
assuming 2s complement so they can do useful things like cryptography.
There's nothing stopping you from writing pure C code that assumes a
2's-complement representation. Just add something like this:
#include <limits.h>
#if INT_MIN == -INT_MAX
#error "This code only works on two's-complement systems."
#endif
in one of your application's header files. (I can imagine the test
not working properly in some bizarre circumstances, but it seems
unlikely.)
Yep -- C99 is 12 point body with 10 point footnotes, C89 was 10 point body
with (I think) 9 point footnotes. If I ever produce another official
copy of the standard, I'm inclined to go back to the smaller type.
If you're taking votes, my vote is to keep the C99 fonts.
A 10 point font is too small for any extended reading
(at least for anyone with eyes past a certain age).
The formatting and layout choices in C99 were quite good.
Al said:Your contributions are welcome, but it may not be obvious, since
you're posting from Google Groups, that the messages you're replying
to are old - only a week for this one, but a month for the other I
just read.
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.