This is the mail archive of the
gsl-discuss@sourceware.cygnus.com
mailing list for the GSL project.
Re: gsl-0.41 and SparcWorks C
- To: Bernd Petrovitsch <bernd@ict.tuwien.ac.at>
- Subject: Re: gsl-0.41 and SparcWorks C
- From: Mark Galassi <rosalia@lanl.gov>
- Date: 02 Aug 1999 10:44:00 -0600
- Cc: gsl-discuss@sourceware.cygnus.com
- References: <199908021336.PAA16163@pc45.ict.tuwien.ac.at>
Dear Bernd,
Thank you very much for your note!
Bernd> I'm compiling gsl-0.41 on Solaris7 and Solaris2.5.1 with
Bernd> the SparcWorks Compiler 4.0 (ok, pretty old ;-).
This kind of feedback is good: nowadays so many people just use gcc
that they get accustomed to its extensions.
Bernd> 1) in sys/prec.c is the GSL_MODE_PREC function defined (for
Bernd> the case that the inline function is ignored). It should
Bernd> have #ifdef HAVE_INLIN= E ... #endif to disable it if
Bernd> GSL_MODE_PREC is defined as a macro (simil= ar to
Bernd> gsl_mode.h).
This was fixed recently, and I wonder if you could tell me if the
version in anonymous CVS works for your compiler.
Bernd> 2) The "const int" definitions in the lines
Bernd> 875, 931 and 932 in specfunc/fermi_dirac.c apparently not
Bernd> usable by SparcWorksCompiler for defining arrays (replacing
Bernd> with #define helped).
You are right. "const int" is valid ISO C, but ISO C says you cannot
use it to size arrays. The new Kernighan and Pike book (The Practice
of Programming) discusses this, and recommends using enums rather than
#define if you wnat to define a constant without the preprocessor.
I've applied the following to CVS, and it will be in the next
release. Does anyone see any objection to this way of doing it?
Index: ChangeLog
===================================================================
RCS file: /cvs/gsl/gsl/specfunc/ChangeLog,v
retrieving revision 1.13
diff -u -r1.13 ChangeLog
--- ChangeLog 1999/02/14 17:33:18 1.13
+++ ChangeLog 1999/08/02 16:43:33
@@ -1,3 +1,10 @@
+1999-08-02 Mark Galassi <rosalia@lanl.gov>
+
+ * fermi_dirac.c: took out the use of some "const int" constants
+ which were being used to size arrays, since this is not portable
+ (thanks to Bernd Petrovitsch <bernd@ict.tuwien.ac.at> for pointing
+ this out).
+
1999-01-02 Mark Galassi <rosalia@cygnus.com>
* trig.c (gsl_sf_rect_to_polar_impl): introduced an #ifdef
Index: fermi_dirac.c
===================================================================
RCS file: /cvs/gsl/gsl/specfunc/fermi_dirac.c,v
retrieving revision 1.25
diff -u -r1.25 fermi_dirac.c
--- fermi_dirac.c 1999/08/01 11:29:32 1.25
+++ fermi_dirac.c 1999/08/02 16:43:35
@@ -872,7 +872,10 @@
int
fd_nint(const int j, const double x, gsl_sf_result * result)
{
- const int nsize = 100 + 1;
+/* const int nsize = 100 + 1; */
+ enum {
+ nsize = 100+1
+ };
double qcoeff[nsize];
if(j >= -1) {
@@ -928,8 +931,12 @@
int
fd_neg(const double j, const double x, gsl_sf_result * result)
{
- const int itmax = 100;
- const int qsize = 100 + 1;
+ enum {
+ itmax = 100,
+ qsize = 100+1
+ };
+/* const int itmax = 100; */
+/* const int qsize = 100 + 1; */
double qnum[qsize], qden[qsize];
if(x < GSL_LOG_DBL_MIN) {