C
Chris Croughton
fopen et al are available of course...
That's not what you wrote: "you can't do anything else but use the
console with putc and getc".
Because they are _stdcall and that is an extension my dear.
But it is in the implementation namespace, since it starts with an
underscore.
Exactly. You get it now. There are several other problems too.
It's something which the compiler could handle (only allow extensions in
MS header files, or whatever, it's undefined by the standard how those
are pulled into the translation unit).
(but it should be
No, it is not possible since for variable argument functions like
printf that convention CAN't be used! I have to keep BOTH you see?
Then you have a problem with the OS, akin to the one with systems which
need hardware access, and have to go outside the standard to do it. For
instance by providing your own libraries of functions to implement the
functionality.
but the OS (or compiler implementer) can always provide their
Of course, I would have to rewrite the 15 000 APIs that Windows
offers and that my compiler allows access to.
Only that. Very easy.
Indeed it is.
And keep 2-5 people maintainig them to keep track of changes to the API
Nope, it can be done with a tool which reads the Windows headers and
generates appropriate functions with C semantics to interface them.
All of this to avoid writing
_stdcall
In the headers.
It can be done. It /is/ done on a number of systems.
There is no mouse, no graphics, no sound, no nothing. Most of the
software written in C uses those, so most of the software in C is
written in a "dialect" then. Who cares?
'Most'? I might agree with "most of the software purchased" (since that
includes all of the MS stuff), but I doubt that its most of the software
written. I have never written professionally[1] a C program which used
a mouse, graphics or sound, and I've written a lot of C code.
OK. Then you can use "pure C" as you wish. lcc-win32 is a C compiler
that targets the Windows desktop platform. Not your stuff.
Indeed. It is also not standard C, and thus is off-topic in
comp.lang.c, no matter how much you keep pushing it.
As I explained already, all the extensions of lcc-win32 are exactly like
that: they do not use the user's namespace and a conforming program
cannot use them explicitely unless they use the extension.
Aparrently not:
For instance a normal C program can't write:
int operator+(myStruct a,myStruct b);
So if they do write this they are using lcc-win32's extensions.
No, they are writing invalid C code for which the standard requires a
diagnostic. Had you named it _operator you might have a leg to stand
on, because the implementation is allowed to define that as an
identifier, but possibly not. As I pointed out, most of the etensions
are things which look like -- and can be implemented as -- macros, so I
can write
void _cdecl __attribute(datasect) int fred(void);
with no problems because an implementation can just do
#define _cdecl
#define __attribute(_x)
if it doesn't support those extensions. However, if a person uses your
operator+ then there is no way of converting it to C code.
Worse, since it alters the semantics and not just the syntax of the
program, there is no way of automatically converting the code which uses
it to standard C (without having a compiler for your language).
Of course. The standard is mistaken. When you like it, you are "FOR
STANDARD C"!! when you do not like it you say the standard is mistaken.
Of course. I have never said that the standard is perfect, nor that its
authors always made the correct decisions (see threads about the
precedence of bit and relational operators, Dennis Ritchie himself has
apparently said that it was wrong). However, any language which has
extensions not covered by the spec. is not compliant, it doesn't matter
how useful the extensions are if they are used by programs those
programs are not C compliant.
That is EXACTLY WHAT I AM DOING. I am letting all users do the
overloading if they wish!
But it isn't standard, and it isn't C. If you want to petition for
adding operator overloading to the C specification, I may well join you
(or I may go the other way and petition to have tgmath.h removed, or to
have typeof added which would also allow the same sort of 'overloading'
of functions as in tgmath.h), but unilaterally adding a feature to a
compiler simply locks the users into that compiler. Which is nice for
you, since people won't be able to resist buying your compiler (as MS
have done for years), but it does nothing to help portable programming
and re-use of code.
The same is of course true of the GCC extensions. I like GCC's version
of macro varargs, and thing that it is better designed than the C99 one,
but if I want to make my programs portable I ignore the extension (in
practice, if I want to make them portable I ignore the C99 extensions as
well, since they are rarely implemented fully as yet).
No, a normal need: It is very difficult and error prone to memorize
several similar function names, and not make a mistake when calling
the one or the other. This is a work that machines do very well. They
can do dumb things very quickly and do not get bored. So why do not
let the machines do the work for you?
However did C programmers manage without them? Quite well, as it
happens, I've never known anyone write production code with bugs of that
form in (it's probably happened, but it's pretty rare). If you don't
know what type your variables are, and it matters, then you'll have a
lot worse problems than forgetting to call sqrtf() instead of sqrt()
(particularly since the base function names take double parameters, so
although that may be better precision than needed it won't be worse).
The names are pretty logical, as well, I no more have to memorise three
names for each than I have to memorise all variants of words in English,
they have consistent suffixes (none for double, f for float and l for
long double).
Although I'm sure 'sqrtl' is a creature from Pokemon(tm)...
Chris C