s-news
[Top] [All Lists]

is_na and gcc

To: S-News <s-news@lists.biostat.wustl.edu>
Subject: is_na and gcc
From: Sundar Dorai-Raj <sundar.dorai-raj@pdf.com>
Date: Wed, 18 Jun 2003 09:43:24 -0500
Organization: PDF Solutions, Inc.
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
Hi all,
I'm unable to use the is_na macro when compiling with gcc and I'm wondering whether this is an S-PLUS issue or a gcc issue?

Below is an example (from the Programmer's guide):

// my_sum.c with an additional line added
#include "S.h"
void my_sum(double *x, long *n, double *sum) {
  long i;
  *sum = 0 ;
  for (i = 0 ; i < *n ; i++) {
    if (is_na(&x[i], S_MODE_DOUBLE)) {
      na_set(sum, S_MODE_DOUBLE);
      break;
    }
    else
      *sum += x[i];
    printf("i = %d; sum = %2.1f\n", i, *sum);
  }
}

$ # compiling using gcc 3.2
$ gcc -c -IC:/Progra~1/Insightful/splus61/include my_sum.c
$ gcc -shared -o S.dll my_sum.o -LC:/Progra~1/Insightful/splus61/lib/mingw -lSqpe

> # in S-PLUS
> my.sum <- function(x) .C("my_sum", as.double(x),
+                          as.integer(length(x)),
+                          double(1), NAOK = T)[[3]]
> my.sum(4:10)
i = 0; sum = 4.0
i = 4; sum = 12.0

Process S+6 exited abnormally with code 5 at Wed Jun 18 09:37:35 2003

It appears as if `i' is being changed in the is_na macro. Removing the is_na check in my_sum.c produces the correct result (i.e. sum = 49). This example works fine when compiling with VC++ 6.0. The gcc compiler I'm using is part of the MinGW distribution (gcc 3.2).

I'm using S-PLUS 6.1 in Win2000.

Regards,
Sundar


<Prev in Thread] Current Thread [Next in Thread>
  • is_na and gcc, Sundar Dorai-Raj <=