 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hi everyone !
Has anyone tried to mix the official POV source code with self-written
C++ code ?
I am using VC5.0 and the compiler does not even recognize the C++
spezific keywords.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Daniel Fenner ha scritto nel messaggio
<36C107FA.E5776109@public.uni-hamburg.de>...
>Hi everyone !
>
>Has anyone tried to mix the official POV source code with self-written
>C++ code ?
>I am using VC5.0 and the compiler does not even recognize the C++
>spezific keywords.
The files have a *.c extension, so the compiler disables C++ syntax. Try to
force C++ compilation: I don't know if there is such an option, you can
anyway rename the files from *.c to *.cpp and try.
Hi
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>The files have a *.c extension, so the compiler disables C++ syntax. Try to
>force C++ compilation: I don't know if there is such an option, you can
>anyway rename the files from *.c to *.cpp and try.
Also, remember to expose you c interface via extern "c" { <prototypes> }
As an example header, that compiles in both C and C++ for VC5.0:
#ifdef __cplusplus
extern "C"
#endif
///////////////////////////////////////////
//
// C Interface for TarFileSystemDatabase
//
void TF_caseSensitive(int flag);
int TF_addTarFile(const char *filename);
int TF_addTarFiles(const char *directory);
FILE *TF_file(const char *filename,const char *mode);
unsigned long TF_sizeOf(const char *filename);
//
//
/////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Nigel Stewart" <nigels> wrote:
: #ifdef __cplusplus
: extern "C"
: #endif
...
: #ifdef __cplusplus
: }
: #endif
How can this work?
--
main(i){char*_="BdsyFBThhHFBThhHFRz]NFTITQF|DJIFHQhhF";while(i=
*_++)for(;i>1;printf("%s",i-70?i&1?"[]":" ":(i=0,"\n")),i/=2);} /*- Warp. -*/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Nieminen Mika schrieb in Nachricht <36c1ba1d.0@news.povray.org>...
>"Nigel Stewart" <nigels> wrote:
>: #ifdef __cplusplus
>: extern "C"
/* insert: */
{
>: #endif
>
>...
>
>: #ifdef __cplusplus
>: }
>: #endif
>
> How can this work?
Then it will work. I've seen this in *all* (Windows-)API header files I've
ever seen.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hi everybody !
First of all : Thanks for the quick response !
some more questions/remarks concerning POV and C++
1) I guess 'extern "C" {...}' is used to include C headers into C++
files
(correct me if I am wrong)
What I need is the opposite : including a C++ header into a C file.
2) As a work-around I compiled the hole source code as C++. (the option
for VC5.0 is /TP) I'm not completly happy with this. A lot of things
had to be changed (prototypes and typecasts mainly) Furthermore the
linker now produces some unresolved references I can not explain.
I used /FORCE and had luck :->.
Does anyone know a 'nicer' way to solve this problem ?
Thanx
Daniel
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Daniel Fenner wrote:
> Hi everybody !
>
> First of all : Thanks for the quick response !
>
> some more questions/remarks concerning POV and C++
>
> 1) I guess 'extern "C" {...}' is used to include C headers into C++
> files
> (correct me if I am wrong)
> What I need is the opposite : including a C++ header into a C file.
>
> 2) As a work-around I compiled the hole source code as C++. (the option
> for VC5.0 is /TP) I'm not completly happy with this. A lot of things
> had to be changed (prototypes and typecasts mainly) Furthermore the
> linker now produces some unresolved references I can not explain.
> I used /FORCE and had luck :->.
>
> Does anyone know a 'nicer' way to solve this problem ?
Yes.
Valid C code is Valid C++ code.
'extern "C"' will prevent the name mangling.
Therefore, write the accessing of your C++ stuffs in a standard C way, plus
use the extern "C" around its definitions in your header files that are to
be included in the plain C code.
Of course, it is possible that a slight redesign in your code may be needed,
as C has no clue as to how to handle C++ specifics. That is to say, you
might need to create some kind of C compatible wrapper around your C++
objects, depending on how the latter are structured and used.
(I think this is just an elaboration on what Nigel posted earlier)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36C3426B.32FC9456@public.uni-hamburg.de> , Daniel Fenner
<Dan### [at] public uni-hamburg de> wrote:
> 1) I guess 'extern "C" {...}' is used to include C headers into C++
> files
> (correct me if I am wrong)
> What I need is the opposite : including a C++ header into a C file.
Some compilers allow to enforce this with a cdecl declaration of a function.
Instead of
void foo();
you would write
void cdecl foo();
However, cdecl is _not_ an ISO C or ISO C++ keyword and might not work with
your compiler.
> 2) As a work-around I compiled the hole source code as C++. (the option
> for VC5.0 is /TP) I'm not completly happy with this. A lot of things
> had to be changed (prototypes and typecasts mainly) Furthermore the
> linker now produces some unresolved references I can not explain.
> I used /FORCE and had luck :->.
Hmm, this is strange. Where were these changes required? In the core code or
in the platform specific code? The core code itself should compile without
error using a C++ compiler...if it does not, it would be very interesting
where VC had problems.
Thorsten
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thorsten Froehlich wrote:
> Hmm, this is strange. Where were these changes required? In the core code or
> in the platform specific code? The core code itself should compile without
> error using a C++ compiler...if it does not, it would be very interesting
> where VC had problems.
>
Just as an aside, when I built the source using VC 5, I get about 710 warnings.
In my experience this is not the best state to leave code in, so what's the
current status on this? (i.e. is it a known and desired state, just something
that needs time to get to, just something to annoy MS compiler users... :-)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On Fri, 12 Feb 1999 00:17:44 -0800, Jon A. Cruz <jon### [at] geocities com> wrote:
>Thorsten Froehlich wrote:
>
>> Hmm, this is strange. Where were these changes required? In the core code or
>> in the platform specific code? The core code itself should compile without
>> error using a C++ compiler...if it does not, it would be very interesting
>> where VC had problems.
>>
>
>Just as an aside, when I built the source using VC 5, I get about 710 warnings.
>In my experience this is not the best state to leave code in, so what's the
>current status on this? (i.e. is it a known and desired state, just something
>that needs time to get to, just something to annoy MS compiler users... :-)
You only get 710? :) Most of them are precision warnings, which are really
kind of a nitpicky kind of warning anyway. I've always just ignored them,
until I can find the time to sit down and fix every single one, or someone
else can. There's definitely a lot of float->double->float conversions going
on in various places, but fixing them would be quite a chore.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Ron Parker wrote:
>
> You only get 710? :) Most of them are precision warnings, which are really
> kind of a nitpicky kind of warning anyway. I've always just ignored them,
> until I can find the time to sit down and fix every single one, or someone
> else can. There's definitely a lot of float->double->float conversions going
> on in various places, but fixing them would be quite a chore.
The MS compliler (at least VC 6) complains about const double -> float
assignments, like:
float x = 2.0;
Which makes for even more warnings.
-Nathan
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36C3E3A8.E381FEDB@geocities.com> , "Jon A. Cruz"
<jon### [at] geocities com> wrote:
> Just as an aside, when I built the source using VC 5, I get about 710
> warnings.
Wow! I get 1592 warnings if I activate the warnings for "implicit aritmmetic
conversions" and "unused arguments".
The point is that the implicit aritmmetic conversions are explicitly
mentioned in the ISO C++ standard and therefore are no code problem. Most
compilers have an option to show these warning. Just find the compiler
switch and deactivate them. The same goes for (currently) unused arguments.
All these warnings are for some reason part of the warning level 1 in VC 5.
The only lower level is level 0 which deactivated all warnings.
I leave it to you to imagine why Microsofts thinks it needs do warn users if
_well documented_ (and used for decades) *ISO* standard behaviour is
expected by the source code (programmer)...
However, you find what the MS progammers think of the standard in remarks
like those for warning C4800.
> In my experience this is not the best state to leave code in, so what's the
> current status on this?
Well, VC 5 is everything but confrom to any C/C++ standard, so don't expect
that all warnings it shows will ever be eliminated :-) Most of its C++
warnings or errors are simply _wrong_ if you comapre it to the ISO C++
standard. I hope (but don't know) that most of these compiler bugs are fixed
in VC 6. If they are not, just use a different compiler. Watcom or
CodeWarrior will do and will generate much faster code as well. The problem
is that they are expensive.
Thorsten
From the ISO 14882 standard (ISO C++ standard):
4 Standard conversions [conv]
1 Standard conversions are implicit conversions defined for built-in types.
4.8 Floating point conversions [conv.double]
1 An rvalue of floating point type can be converted to an rvalue of another
floating point type. If the source value can be exactly represented in the
destination type, the result of the conversion is that exact representation.
If the source value is between two adjacent destination values, the result
of the conversion is an implementation-defined choice of either of those
values. Otherwise, the behavior is undefined.
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: Tho### [at] csi com
I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://www.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36c429f4.0@news.povray.org> , par### [at] my-dejanews com (Ron
Parker) wrote:
> You only get 710? :) Most of them are precision warnings, which are really
> kind of a nitpicky kind of warning anyway. I've always just ignored them,
> until I can find the time to sit down and fix every single one, or someone
> else can. There's definitely a lot of float->double->float conversions going
> on in various places, but fixing them would be quite a chore.
Ron, it is nearly useless to try to remove this because it all is a result
of the macro DBL. If a platform defines it to float you get different
problems. If you add explicit type casts it will even be dangerous for other
platforms: You force the compiler to convert the type and if the platform
does not support native double precision floating point values, it will
rsult in much slower execution.
Thorsten
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: Tho### [at] csi com
I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://www.povray.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thorsten Froehlich wrote:
> > In my experience this is not the best state to leave code in, so what's the
> > current status on this?
>
> Well, VC 5 is everything but confrom to any C/C++ standard, so don't expect
> that all warnings it shows will ever be eliminated :-) Most of its C++
> warnings or errors are simply _wrong_ if you comapre it to the ISO C++
> standard. I hope (but don't know) that most of these compiler bugs are fixed
> in VC 6. If they are not, just use a different compiler. Watcom or
> CodeWarrior will do and will generate much faster code as well. The problem
> is that they are expensive.
>
Yes, I understand much of this, but... the benefit I found in cleaning up those
warnings in other work helped in cleaning up code I've done in various
cross-platform work (DOS, OS/9, Win16, Unix, Win32, Linux ).
Now, the float/double issue could stand some investigation, and that is exactly
the kind of information I was looking for.
One side effect is that all those float/double warnings make it hard to spot the
significant warnings such as those from truetype.c:
warning C4101: 'i' : unreferenced local variable
warning C4018: '<' : signed/unsigned mismatch
warning C4244: '=' : conversion from 'unsigned short ' to 'unsigned char ',
possible loss of data
warning C4244: '=' : conversion from 'double ' to 'short ', possible loss of data
...
warning C4700: local variable 'len' used without having been initialized
Personally, I think the "unreferenced local variable" warnings that MS pops out
(even on it's java compiler) are extremely handy. Also, the signed/unsigned
mismatch gets very significant for font glyphs where the values are 16-bit
Unicode glyphs that are getting mapped from 8-bit chars, etc.
So, I have the float/double issue to mask and investigate later. Any others that
I should be aware of, or should I just go head and do some nit-picking and submit
my changes? (I know not to complain about anything without be willing to do
something about it).
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36C52BCA.8AED0DA7@geocities.com> , "Jon A. Cruz"
<jon### [at] geocities com> wrote:
> Yes, I understand much of this, but... the benefit I found in cleaning up
> those warnings in other work helped in cleaning up code I've done in various
> cross-platform work (DOS, OS/9, Win16, Unix, Win32, Linux ).
So far, there have been no (major) problems with POV-Ray in cross-platform
functionality...
> One side effect is that all those float/double warnings make it hard to spot
> the significant warnings such as those from truetype.c:
>
> warning C4101: 'i' : unreferenced local variable
Compilers in general don't generate any code for unused variables...so this
is not serious, it only shows the constant development of the source code
:-)
> warning C4018: '<' : signed/unsigned mismatch
This is more interesting, but most likely not that serious at all.
> warning C4244: '=' : conversion from 'unsigned short ' to 'unsigned char ',
> possible loss of data
> warning C4244: '=' : conversion from 'double ' to 'short ', possible loss of
I have not tried, but if you do an explicit type cast, does this warning go
away? (And personally, I think that the warning "possible loss of data" is
a very bad wording, the correct wording for this is "possible loss of
precision"...well MS calls "bug fixes" "service packs", so I guess for them
it makes sense ;-)
> warning C4700: local variable 'len' used without having been initialized
This warning is mileading (also it is correct), this is the only case in the
source code this happens: len is passed by pointer to a function that then
returns a value though it.
> Personally, I think the "unreferenced local variable" warnings that MS pops
> out (even on it's java compiler) are extremely handy.
Yes, they are useful! I don't know any compiler that does not have at least
a switch to do so. :-)
> Also, the signed/unsigned
> mismatch gets very significant for font glyphs where the values are 16-bit
> Unicode glyphs that are getting mapped from 8-bit chars, etc.
Yes, it does.
> So, I have the float/double issue to mask and investigate later. Any others
Please read my reply to Ron Parker regarding the float/double conversion as
well. Personally I think that there is no reason to change this at all, why
change code that hasn't created to any problems in the last 8 years?
> that I should be aware of, or should I just go head and do some nit-picking
> and submit my changes? (I know not to complain about anything without be
> willing to do something about it).
As Chris Young announced, there will be a 3.5 version. So just that you
don't do done work again: Cleaning up the unused variables, "len" not being
initialized and the unsuded function argument warnings have been cleaned up.
If you have more/other changes (like the Unicode patch) I would suggest to
e-mail Chris Young (C_Y### [at] compuserve com), explain your changes and ask
him how to submit them (don't send a large file at once). He gets a lot of
e-mail (I guess) and it might take a few days for him answer your e-mail.
Oh, and please be very careful when changing/using types. I saw in your
Unicode patch (at least in the first version) that you used wchar_t. This
might work with most compilers, but USHORT is the type to use in truetype.c.
This helps a lot when integrating a patch.
Thorsten
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thorsten Froehlich wrote:
> Oh, and please be very careful when changing/using types. I saw in your
> Unicode patch (at least in the first version) that you used wchar_t. This
> might work with most compilers, but USHORT is the type to use in truetype.c.
> This helps a lot when integrating a patch.
>
Yes, that's probably the area that I need to watch the most. I won't consider my
code done 'till that kind of stuff is all resolved.
With wchar_t itself you get the same issue as with the float/double conversions
and int size. It's designated to contain Unicode characters, but may or may not be
16-bits. Some systems are reported to be using 32-bits for processor efficiency,
so just imagine if I pass an array of 16-bit values to a C call expecting 32-bit
values.
So, that's why I start with wchar_t. If, however, no wide-char API calls are made,
then USHORT should be no problem.
Oh, and I'll wait on the cleanup. I can always run my compiler output through
grep. See, it's good to ask these things, so as not to duplicate effort.
BTW, anyone compiling POV-Ray for 64-bit processors?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36C### [at] geocities com> , "Jon A. Cruz"
<jon### [at] geocities com> wrote:
> With wchar_t itself you get the same issue as with the float/double
> conversions and int size. It's designated to contain Unicode characters, but
> may or may not be 16-bits. Some systems are reported to be using 32-bits for
> processor efficiency, so just imagine if I pass an array of 16-bit values to a
> C call expecting 32-bit values.
>
> So, that's why I start with wchar_t. If, however, no wide-char API calls are
> made, then USHORT should be no problem.
There are no C calls that expect it, wchar_t is a C++ keyword and there is
no standard C library that will expect or take it.
Thorsten
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thorsten Froehlich wrote:
> In article <36C### [at] geocities com> , "Jon A. Cruz"
> <jon### [at] geocities com> wrote:
>
> > With wchar_t itself you get the same issue as with the float/double
> > conversions and int size. It's designated to contain Unicode characters, but
> > may or may not be 16-bits. Some systems are reported to be using 32-bits for
> > processor efficiency, so just imagine if I pass an array of 16-bit values to a
> > C call expecting 32-bit values.
> >
> > So, that's why I start with wchar_t. If, however, no wide-char API calls are
> > made, then USHORT should be no problem.
>
> There are no C calls that expect it, wchar_t is a C++ keyword and there is
> no standard C library that will expect or take it.
>
But it is in C. It is in Normative Addendum 1. I was just using that as an example.
People working on internationalization stuff on Windows or Intel Linux might assume
16-bit when it gets 32 bits. Also, besides the standard, it is possible for people
to write routines (like the ones I did in uniutils.c) that operate on theses, and
then the difference would matter. That is what will probably have the most impact,
so the proper considerations should be made. That's all.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36C### [at] geocities com> , "Jon A. Cruz"
<jon### [at] geocities com> wrote:
> But it is in C. It is in Normative Addendum 1.
Hmm, I don't have the ISO C standard documentation nor its later changes,
but my point was that it is not used in the standard C library.
Thorsten
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> You only get 710? :) Most of them are precision warnings
>Ron, it is nearly useless to try to remove this because it all is a result
>of the macro DBL
DBL x = 2.0;
becomes
DBL x = (DBL) 2.0;
Is there anything unreasonable or dangerous about doing this?
I think it is worth keeping the MS compiler quiet, because sometimes
things like signed/unsigned, unused, uninitialised variable, actually
help solve problems.
Has anyone run POV through Purify, or Bounds Checker?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Yes, but you'll still get errors for the Assign_SNGL_Vect macro... it
doesn't know if you're assigning from doubles or singles.
-Nathan
Nigel Stewart wrote:
>
> >> You only get 710? :) Most of them are precision warnings
>
> >Ron, it is nearly useless to try to remove this because it all is a result
> >of the macro DBL
>
> DBL x = 2.0;
>
> becomes
>
> DBL x = (DBL) 2.0;
>
> Is there anything unreasonable or dangerous about doing this?
> I think it is worth keeping the MS compiler quiet, because sometimes
> things like signed/unsigned, unused, uninitialised variable, actually
> help solve problems.
>
> Has anyone run POV through Purify, or Bounds Checker?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36c76403.0@news.povray.org> , "Nigel Stewart"
<nig### [at] eisa net au NOSPAM> wrote:
> DBL x = 2.0;
>
> becomes
>
> DBL x = (DBL) 2.0;
>
> Is there anything unreasonable or dangerous about doing this?
It is unreasonable: DBL x = 2.0; is c acompletly legal and *well* readable
statement. DBL x = (DBL) 2.0 is less readable. Putting unnecessary code into
POV-Ray just to get rid of *one* compilers warnings is _not_ reasonable.
> I think it is worth keeping the MS compiler quiet, because sometimes
> things like signed/unsigned, unused, uninitialised variable, actually
> help solve problems.
Ever considered a different compiler? ;-)
Thorsten
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> DBL x = 2.0;
>> becomes
>> DBL x = (DBL) 2.0;
>>
>> Is there anything unreasonable or dangerous about doing this?
>
>It is unreasonable: DBL x = 2.0; is c acompletly legal and *well* readable
>statement. DBL x = (DBL) 2.0 is less readable.
But the meaning is more precise. I think the benefit of clarity and
portability outweigh your concern - but that's entirely my opinion.
While the first line says "I want 2.0 assigned to x", the second says
"I knowingly want 2.0 converted to a DBL, and assigned to x".
For example, if you use a float as an intermediate result, treat it as a
double later, and wonder why you're not getting the expected precision -
the explicit cast will be something of a clue. Your preference is
to be oblivious to truncation.
It's a fine point, but I think it is more than just a platform/compiler
quirk - in this case Microsoft have done something for a sound
technical reason. (I wish they'd do so more often!)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36c7a4da.0@news.povray.org> , "Nigel Stewart"
<nig### [at] eisa net au NOSPAM> wrote:
>>> DBL x = 2.0;
>>> becomes
>>> DBL x = (DBL) 2.0;
>>>
>>> Is there anything unreasonable or dangerous about doing this?
>>
>>It is unreasonable: DBL x = 2.0; is c acompletly legal and *well* readable
>>statement. DBL x = (DBL) 2.0 is less readable.
>
>But the meaning is more precise. I think the benefit of clarity and
>portability outweigh your concern - but that's entirely my opinion.
Hmm, there are no (and as far as I know have never been) portability
problems with floating point type casting. While I is might sometimes be
useful to do so in code like
SNGL sfp = 2.0;
DBL dfp = 8.0;
sf = (SNGL)(spf * dfp);
doing it for DBL x = (DBL) 2.0 is not only less readable, but even
redundant! It is defined in the ISO C++ standard that a type float value
will be *implicitly* converted to a type double value without loss of
precision. If you suggest doing DBL x = (DBL) 2.0 why not doing the same for
short x = (short)5, or long y = (long)7 because the native type of 5 and 7
would is assumed to be int by some compiler...
My opinion (and those who wrote the ISO C++ standard) is that writing
explicit conversion in these cases is redundant.
>While the first line says "I want 2.0 assigned to x", the second says
>"I knowingly want 2.0 converted to a DBL, and assigned to x".
I am wondering: What is the type of "2.0" for you? For me its type is the
largest floating point type supported by the implementation.
>For example, if you use a float as an intermediate result, treat it as a
>double later, and wonder why you're not getting the expected precision -
Yes, then you will have to check manually *every* cast because your compiler
can no longer tell you where the implicit conversion is happening! The goal
is to use as few casts as necessary, and casting *is* dangerous,for example
signed char f;
f = (signed char)(180); // Assumes sizeof(signed char) == 1 !!!
will no longer show an (optional) compiler warning because you explicitly
*forced* the compiler to do this while you have a chance to find the problem
writing
signed char f;
f = 180;
>the explicit cast will be something of a clue. Your preference is
>to be oblivious to truncation.
No, as the example above shows, it does exactly the opposite!
>It's a fine point, but I think it is more than just a platform/compiler
>quirk - in this case Microsoft have done something for a sound
>technical reason. (I wish they'd do so more often!)
Well, most compilers have this, but then they have it as an *option*, they
don't force these warnings!
And my opinion is that *standard* (Microsoft also worked in the ISO C++
commitee) behaviour should not show warnings by default. Doing so is a
misleading bug.
Thorsten
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>It's a fine point, but I think it is more than just a platform/compiler
>>quirk
>
>Well, most compilers have this, but then they have it as an *option*, they
>don't force these warnings!
One man's bug is another man's feature. As I recall your objection -
"Just because MS VC complains, doesn't mean we should fix it"
If you're not using MS VC, why complain about the behavior of it?
I think it is appropriate to be explicit about floating point
truncation in the context of numerically sensitive code.
To me, an explicit cast indicates a "Yes I'm sure I want
to do this", to you it's a nuisance. I've found that paranoid
warnings actually help avoid problems later on - why do
you insist that making use of this information is
"non-standard" or that the compiler is "buggy" for doing
so?
I am not advocating "automatic explicit casting" as your
example may suggest. I like to see code compiling clean
on different platforms. I don't mind having to dot my
i's and crossing my t's to appease each different compiler,
it actually reveals something about the maturity and
philosophy of the compiler.
It sounds like we're both arguing from experience,
from different perspectives. You're pointing to
the standard treatment of floats and doubles in
the context of implicit casting. I'm pointing to the
(pragmatic) benefit of identifying bugs early.
We like to make different trade-offs.
And uh, I think we both need to keep in mind that this
argument is pretty academic. It doesn't bother me
greatly enough to upset a fellow povray developer,
or get them offside. So, if you're feeling that I'm a total
heretic for not agreeing with you, let me know and
I'll argue less strongly.. :-) I 99% agree with everything
you say anyway!
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Nigel Stewart" <nig### [at] eisa net au NOSPAM> writes:
[...]
>
> Has anyone run POV through Purify, or Bounds Checker?
Yes. I've made some tests with purify on Sun Solaris. There weren't any
errors reported. In my opinion, this is an amazing quality for software.
Of course, I could only test a small subset of the POV-Ray features.
By the way, I have found some problems with the isosurface patch. One has
been fixed by Suzuki Ryoichi. Unfortunately, some other errors appear only in
very large scenes (i.e. hundreds of parametric surfaces).
Thomas
--
http://www.fmi.uni-konstanz.de/~willhalm
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>If you suggest doing DBL x = (DBL) 2.0 why not doing the same for
>short x = (short)5, or long y = (long)7 because the native type of 5 and 7
>would is assumed to be int by some compiler...
Ahhh... Here is our misunderstanding. You interpret me as saying
that you should never rely on implicit casting. My meaning is that
you need to be careful about implicit casting of floats and doubles.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <36c7e6b6.0@news.povray.org> , "Nigel Stewart"
<nig### [at] eisa net au NOSPAM> wrote:
> Ahhh... Here is our misunderstanding. You interpret me as saying
> that you should never rely on implicit casting. My meaning is that
> you need to be careful about implicit casting of floats and doubles.
>
> And uh, I think we both need to keep in mind that this
> argument is pretty academic. It doesn't bother me
> greatly enough to upset a fellow povray developer,
> or get them offside. So, if you're feeling that I'm a total
> heretic for not agreeing with you, let me know and
> I'll argue less strongly.. :-) I 99% agree with everything
> you say anyway!
Yes, that is true. I have no problem with your argument nor with the way you
are arguing. (And I hope you don't have a problem with my style either :-)
It is just that we disagree in when some casts are useful and when a
compiler should notify the programmer by default when implicity casts are
used.
Thorsten
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On Sun, 14 Feb 1999 19:53:29 -0600, Thorsten Froehlich wrote:
>In article <36c76403.0@news.povray.org> , "Nigel Stewart"
><nig### [at] eisa net au NOSPAM> wrote:
>
>> DBL x = 2.0;
>>
>> becomes
>>
>> DBL x = (DBL) 2.0;
>>
>> Is there anything unreasonable or dangerous about doing this?
>
>It is unreasonable: DBL x = 2.0; is c acompletly legal and *well* readable
>statement. DBL x = (DBL) 2.0 is less readable. Putting unnecessary code into
>POV-Ray just to get rid of *one* compilers warnings is _not_ reasonable.
>
>> I think it is worth keeping the MS compiler quiet, because sometimes
>> things like signed/unsigned, unused, uninitialised variable, actually
>> help solve problems.
>
>Ever considered a different compiler? ;-)
Ever run PC-Lint against POV? I haven't tried yet, but in my experience
with real code, it's far more picky than Visual C++ is.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |