[R-pkg-devel] Problem (with complex.h?) under Microsoft Windows

Pierre Lafaye de Micheaux lafaye at dms.umontreal.ca
Fri Nov 13 17:24:41 CET 2015

Dear all,

I created a new version of the package IndependenceTests where I call 
some C and Fortran functions (using the .C() or .Fortran() interface).
It works perfectly under Linux, with gcc. No problem with R CMD check. I 
would like to upload this package on the CRAN.

But when I first tried to use winbuilder, I got an error with the 
following message:

* installing *source* package 'IndependenceTests' ...
** libs

*** arch - i386
g++  -I"D:/RCompile/recent/R/include" -DNDEBUG 
-I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall 
-mtune=core2 -c Cnhat.cpp -o Cnhat.o
Cnhat.cpp:9:89: error: 'complex' has not been declared
Cnhat.cpp:9:105: error: two or more data types in declaration of 'res'

I think I understand that there is a problem (only under Windows though) 
with the complex type.
The beginning of my file Cnhat.cpp is as follows:

1. #include <R.h>
2. #include "Rmath.h"
3. #include <complex.h>
4. #include <iostream>
5. using namespace std;
7. extern"C" {
9.   void CnhatC(double *vecs, double *vect, double *X, int *n, int *q, 
int *p, int *vecd, complex double *res) {
11.    void phinhatReturn(double *vect1, double *vect2, double *vect3, 
double *X, int *q, int *n, double _Complex *res1, double _Complex *res2, 
double _Complex *res3);
12.    double _Complex tmp2, prod1 = 1.0 + 0.0*_Complex_I, prod2 = 1.0 + 
0.0*_Complex_I, somme = 0.0 + 0.0*_Complex_I;
13.    int indbeginblocl, l, i, *vecdl, k, j;
14.    double *vecsl, *mvectl, *diffvecsvectl, *Xl;
15.    double _Complex *res1, *res2, *res3;
16.    vecdl = new int[1];
17.    res1 =  new _Complex double[1];

As you can see, there seem to be some problem (on line 9.) with: complex 
double *res

Could you please point me to something (e.g., another package) that 
might help me solve the problem? If possible, I would like to avoid 
invest too much time using the new .Call() interface because I am quite 
with the old .C(). And also I am not even sure if it would help solving 
the problem.

Best regards,

Pierre L.

Pierre Lafaye de Micheaux

Adresse courrier:
Université de Montréal
Pavillon André-Aisenstadt
Département de Mathématiques et Statistique
CP 6128 Succursale Centre-ville
Montréal Qc H3C 3J7

Adresse physique:
Département de Mathématiques et Statistique
Bureau 4249, Pavillon André-Aisenstadt
2920, chemin de la Tour
Montréal, Québec H3T 1J4

Tél.: (00-1) 514-343-6607 / Fax: (00-1) 514-343-5700
lafaye at dms.umontreal.ca

	[[alternative HTML version deleted]]

More information about the R-package-devel mailing list