The R Project SVN R

Rev

Rev 71657 | Rev 84153 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 71657 Rev 84135
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 1998-2001   The R Core Team
3
 *  Copyright (C) 1998-2023   The R Core Team
4
 *
4
 *
5
 *  This header file is free software; you can redistribute it and/or modify
5
 *  This header file is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU Lesser General Public License as published by
6
 *  it under the terms of the GNU Lesser General Public License as published by
7
 *  the Free Software Foundation; either version 2.1 of the License, or
7
 *  the Free Software Foundation; either version 2.1 of the License, or
8
 *  (at your option) any later version.
8
 *  (at your option) any later version.
Line 28... Line 28...
28
 
28
 
29
#ifdef  __cplusplus
29
#ifdef  __cplusplus
30
extern "C" {
30
extern "C" {
31
#endif
31
#endif
32
 
32
 
-
 
33
# ifdef R_LEGACY_RCOMPLEX
-
 
34
 
-
 
35
/* This definition does not work with optimizing compilers which take
-
 
36
advantage of strict aliasing rules.  It is not safe to use with Fortran
-
 
37
COMPLEX*16 (PR#18430) or in arguments to library calls expecting C99
-
 
38
_Complex double.  This old definition should not be used, but if it were
-
 
39
still necessary, one should at least disable LTO.  This may be removed at
-
 
40
any time.  */
-
 
41
 
33
typedef struct {
42
typedef struct {
-
 
43
 	double r;
-
 
44
 	double i;
-
 
45
 } Rcomplex;
-
 
46
 
-
 
47
# else
-
 
48
 
-
 
49
/* This definition uses an anonymous structure, which is defined in C11 (but
-
 
50
not C99).  It is, however, supported at least by GCC, clang and icc.  The
-
 
51
private_data_c member should never be used in code, but tells the compiler
-
 
52
about type punning when accessing the .r and .i elements, so is safer to use
-
 
53
when interfacing with Fortran COMPLEX*16 or directly C99 _Complex double
-
 
54
(PR#18430).
-
 
55
 
-
 
56
This form of static initialization works with both definitions:
-
 
57
Rcomplex z = { .r = 1, .i = 2 }; */
-
 
58
 
-
 
59
typedef union {
-
 
60
    struct {
34
	double r;
61
	double r;
35
	double i;
62
	double i;
-
 
63
    };
-
 
64
    double _Complex private_data_c;
36
} Rcomplex;
65
} Rcomplex;
37
 
66
 
-
 
67
# endif 
-
 
68
 
38
#ifdef  __cplusplus
69
#ifdef  __cplusplus
39
}
70
}
40
#endif
71
#endif
41
 
72
 
42
#endif /* R_COMPLEX_H */
73
#endif /* R_COMPLEX_H */