On 2011-12-03 09:01-0000 Andrew Ross wrote:

>
> I have just committed a fairly large update to change the 2d arrays in
> our API from const PLFLT ** to const PLFLT * const *. Gcc warns about
> the use of const PLFLT ** because it only guarantees that the data is
> constant not the array of pointers to the data. It is therefore trivial
> to change the data by changing the pointers which is not what is
> intended. Both the pointer array and the data need to be marked const.
>
> This is quite intrusive, but it seems to work ok for me. Please check.
> It is strictly an API change however existing code should still
> compile fine (possibly with warnings depending on the gcc settings).
>
> This does not remove all warnings - just shifts them (more later). It
> does however make the API and the examples clean which I think is
> more important for users.
>
> The const PLFLT * const * is a bit unwieldy however, so I propose
> making a new typedef (something like PLFLT_2D_CONST) to tidy up
> the code.

Assuming PLFLT is #defined like we have done, is "PLFLT * const *"
something all c99-compliant compilers should understand or is that
just a gcc extension?  Even if the answer to that question is all
c99-compliant compilers should understand it, it is possible their c99
implementations are buggy.  Therefore, I think using a PLFLT_2D_CONST
typedef (which we could #define differently for any major
non-compliant compilers) might be a good idea from cross-platform
point of view as well.

For what it is worth, revision 12095 passes a limited test
(just test_noninteractive in the build tree) on my Debian stable platform
(gcc (Debian 4.4.5-8) 4.4.5). Furthermore, for that test using

CXXFLAGS=-O3 -fvisibility=hidden
CFLAGS=-O3 -fvisibility=hidden
FFLAGS=-O3

there were no compiler warnings at all.  That good result surprised me
because there used to be tonnes of Java warnings and a sprinkling of C
warnings.  I don't know whether the Java warnings disappeared due to
your efforts, but in any case we have come a long way in getting our
code cleaned up thanks to your much appreciated efforts.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to