CnUnix

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ CnUnix ] in KIDS
글 쓴 이(By): darkman (아랑타불)
날 짜 (Date): 2004년 7월 16일 금요일 오후 11시 13분 08초
제 목(Title): Re: [Q]켅99에서 복소수


This is about cabs and friends on IRIX, but even so, not at all: IRIX
6.5.18 and up have C99 support, which is done like this:

<internal/math_core.h> (included from <math.h>) has

#if !defined(__c99)
struct __cabs_s { double a,b; };

extern double   cabs(struct __cabs_s);
[...]
#endif

and <complex.h> has

/* C99: 7.3.8.1 */

/* c89 also had functions cabs, cabsf and cabsl with the following
 * prototypes.
 *
 * double cabs (struct { double a,b; } z);
 * float cabsf (struct { float a,b; } z);
 * long double cabsl (struct { long double a,b; } z);
 *
 * As the passing of structs by value is different from passing
 * complex by value for the float and long double cases, the following
 * changes are being done to the C99 functions so as to maintain
 * backwards compatibility.
 * 
 * For the C99 functions we provide static definitions of these,
 * which in turn call the corresponding library functions with a __c99_
 * prefix.
 *
 * There are two drawbacks of this approach
 *
 *  1.  As each compilation will get its own copy of these functions,
 *      any program which relies on the address of these functions being
 *      unique will fail.
 *
 *  2.  If the user rolls his own version of these functions, they will
 *      never get invoked, and to get around this problem, the user
 *      should be able to disable the generation of these static 
functions.
 *      This is achieved by adding -D_C99_CABS_USER_DEFINED to the 
commandline.
 */


extern double      __c99_cabs  (double complex);
extern float       __c99_cabsf (float complex);
extern long double __c99_cabsl (long double complex);
#pragma optional   __c99_cabs
#pragma optional   __c99_cabsf
#pragma optional   __c99_cabsl

#ifdef _C99_CABS_USER_DEFINED

extern double       cabs  (double complex);
extern float        cabsf (float complex);
extern long double  cabsl (long double complex);

#else 

static inline double cabs       (double complex z)      {return 
__c99_cabs(z); }
static inline float  cabsf      (float complex z)       {return 
__c99_cabsf(z);}
static inline long double cabsl (long double complex z) {return 
__c99_cabsl(z);}

#endif /* _C99_CABS_USER_DEFINED */


인터넷에 보니 이런글도

[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.