Wrong. Please read the standard and see in page 7:
Extensions are not forbidden, if implemented according to the
constraints that I followed.
No, you did not, you implemented them in the user namespace.
The -ansic flag disallows any extensions, and all
functions not in the standard. No windows.h no
network, etc etc.
Not much use then, if it can't use external libraries and headers --
which /are/ allowed by the standard.
Extensions are a common feature of most C compilers
and systems. The standard sets a minimum language,
but all implementation implement extensions in one way or
another.
All? Well, perhaps you've checked every C compiler in existence.
Although extensions are necessary for some features of C99.
Is gcc in non pedantic mode not a C compiler any more?
Correct, it adds certain features (like asm) in the user namespace, thus
implementing a language almost, but not quite, C (indeed, with no
language specified the default is a language somewhere between C89 and
C99, with extra non-standard bits).
And Microsoft with their __declspec(...) is no longer C?
__declspec is in the implementation namespace, which is allowed by the
standard. Of course, they have had other inconsistencies as well...
Let's be realistic and discuss the issues here.
A user asked about how to implement overloaded functions because
he needs them, they are useful. Most languages have this feature
in one way or another, from C# to C++ passing through all OO
languages, etc.
And the answer is "They don't exist in C". If you want them, use
another language (C++ is a standard, for instance).
I understand C not as a freezed language that shuns any
improvement but as a language that should be as easy to
use as possible and that allows to construct modern software.
It certainly does the latter. If you want "as easy to use as possible"
I suspect you want LOGO or a form of BASIC.
Overloaded functions allow more flexibility in the implementation
and less impact in the memory space of the user. Calling a
function
sqrt_for_long_doubles
sqrt_for_double
sqrt_for_float
just makes things more difficult to remember.
Well, if those were the names they'd be easy to remember but hard to
type correctly. But fsqrt and lsqrt are pretty easy to remember,
particularly since they are consistent with the other maths functions'
naming. I would have liked to see dsqrt as a synonym for sqrt, just for
consistency, but I'm not too fussed about it.
This is a plain truth, so much so, that the standard specifies
the overloaded function sqrt for all of those types.
Only with the hideous tgmath.h extensions, which do indeed require
extensions (but not actually overloading, although they have that
effect).
That was a good idea, that I made available to the users of my
compiler system. Why the implementor should have something
that user's can't use? If the implementor uses them, they are
needed and the user have a right to use that too.
Indeed, I think that if they were going to allow it at all then it
should have been specified properly.
BUT IT WASN'T. That is the point, that no matter how much you want it
that feature IS NOT C.
Calling all those three functions sqrt (as the standard header
tgmath defines) makes programming in C easier.
I just made that idea available to the users.
And thereby created another language variant. It is not C, it is "C
with extensions".
Let's stop the polemic and discuss the issues at hand. All of this
"I am holier than you" discussion is a waste of time.
The issue is that a person asked whether overloaded functions are
available in C. The correct answer is simple, they are not. You,
however, attempted to mislead by pushing your almost-C compiler which
has them as extensions (and without pointing out that this is a
non-standard feature and is only available on one platform). That is
fraud,
Have you anything against genericity? Should be eliminate tgmath
from the standard then?
My preference is yes. It isn't needed (if you don't know what type you
want, your design is faulty, if it matters then you need to be able to
specify it). My next preference is that if they really think that
overloading is useful then it should be made generally available as a
standard feature.