Date: Wed, 02 Mar 2005 17:34:33 +0100 From: Andrea Venturoli <ml@netfence.it> To: Florian Hengstberger <e0025265@student.tuwien.ac.at> Cc: FreeBSD mailinglist <freebsd-questions@freebsd.org> Subject: Re: c standard Message-ID: <4225EB19.3070704@netfence.it> In-Reply-To: <icqfqw.8f29so@webmail.tuwien.ac.at> References: <icqfqw.8f29so@webmail.tuwien.ac.at>
next in thread | previous in thread | raw e-mail | index | archive | help
Florian Hengstberger wrote:
We are OT, anyway...
> Following is possible with gcc and g++:
These are two quite different cases: gcc is normally for C, g++ for C++.
Contrary to what many people believe, they are two very different languages.
> #include <math.h>
If you are using C++ you should not #include <math.h>, but #include <cmath>
> double sin(double)
> {
> return 1;
> }
>
> Why I don't get any warnings like:
> sin prevously defined in math.h ...
Mainly because it isn't. In math.h (or cmath) sin is only declared, not
defined.
There might possibly be other reasons: like the fact that in C++,
provided you correctly included <cmath> and not <math.h>, the standard
sin will be in namespace std, not in the global one.
> Why is it possible to overwrite the definition of sin,
> is this part of the standard?
Again, you are providing *a* definition; there is no previous one at
this point to override.
> Secondly the definition (not declaration) of double sin(double)
> misses a variable!
You are not missing any variable; you are merely not assigning it any name.
> Is this ok, when the variable is not referenced in the code?
Exactly.
bye
av.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4225EB19.3070704>
