POV-Ray : Newsgroups : povray.beta-test : master branch issue 29 linux compilation errors : Re: master branch issue 29 linux compilation errors Server Time
29 Apr 2024 02:58:28 EDT (-0400)
  Re: master branch issue 29 linux compilation errors  
From: clipka
Date: 30 Jun 2014 08:26:08
Message: <53b15760$1@news.povray.org>
Am 29.06.2014 11:52, schrieb Le_Forgeron:

--------
./base/colour.h: In instantiation of ‘T 
pov_base::GenericColour<T>::MaxAbs() const [with T = float]’:
./base/colour.h:1422:27:   required from ‘T 
pov_base::GenericColour<T>::WeightMaxAbs() const [with T = float]’
backend/render/trace.cpp:999:34:   required from here
./base/colour.h:1456:54: error: no matching function for call to 
‘max(float&, double)’
                  result = max(result, fabs(mColour[i]));
--------

That's a quite interesting error we have here: With T=float, mColour is 
defined as "float mColour[3]", so the compiler should pick "float 
fabs(float)", but the max() signature it is trying to find a match for 
indicates that the compiler rather chooses "double fabs(double)".

So either...:

(A) The compiler is buggy, or

(B) The header files are buggy, declaring "fabs(float)" as returning a 
double instead, in obvious violation of the C++03 standard, or

(C) The header files are buggy, failing to declare "fabs(float)" at all, 
again in obvious violation of the C++03 standard.

So we should probably contact the authors of g++ to fix this...


... or should we? Having had a quick glance at the C++03 standard, 
thruth gave me a roundhouse kick right in the face:

(D) We're not including the right header in the first place.


Just a few weeks ago, I had done some work on work coding style; one 
thing I addressed was the order in which header files should be 
included, as well as which names should be used for C standard headers. 
One thing that had been bugging me most was the inconsistenty in using 
the old C standard header file names vs. the new C++ names (e.g. 
<stdlib.h> vs. <cstdlib>), and I went for the C++ names for the coding 
rules; it had been bugging me to the degree that in all the files I have 
been touching ever since, I replaced all the C header names with the C++ 
names.

Well, it should probably have bugged me even more.

 From ISO-IEC 14882-2003 (aka C++03):
-------------------------------------------------
26 Numerics library
[...]
26.5 C Library

Tables 80 and 81 describe headers <cmath> and <cstdlib> [...], respectively.
[...]
The contents of these headers are the same as the Standard C library 
headers <math.h> and <stdlib.h> respectively, with the following additions:
[...]
     float fabs (float);
[...]
-------------------------------------------------

Read this again, and let it sink in: <cmath> is /not/ a C++ canonical 
name for <math.h>. It is an entirely different library, with /added/ 
functionality over <math.h>.

Guess which version of <math.h> / <cmath.h> we've been including in 
POV-Ray all the time...


I think it's time to kick out all the C standard header files for good. Now.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.