Re: Question about (double *)NULL
- From: "A. Bolmarcich" <aggedor@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 30 Apr 2006 17:28:50 -0000
On 2006-04-30, Rouben Rostamian <rouben@xxxxxxxxxxxxxxxxxx> wrote:
Umfpack is a C library for computations dealing with sparse
matrices. Several examples in the User's Guide use a certain
cast that puzzles me. Here is an example.
The prototype of the function umfpack_di_symbolic() is:
int umfpack_di_symbolic
(
int n_row,
int n_col,
const int Ap [ ],
const int Ai [ ],
const double Ax [ ],
void **Symbolic,
const double Control [UMFPACK_CONTROL],
double Info [UMFPACK_INFO]
);
The header file umfpack.h has:
#define UMFPACK_CONTROL 20
Here is a sample usage:
int main (void)
{
double *null = (double *) NULL ;
...
(void) umfpack_di_symbolic (n, n, Ap, Ai, Ax, &Symbolic, null, null) ;
...
return (0) ;
}
(Code fragments are put here by "cut-and-paste"ing from the manual.)
My question is: Does the cast in (double *)NULL accomplish anything?
It seems to me that the call to umfpack_di_symbolic() equivalent to:
umfpack_di_symbolic (n, n, Ap, Ai, Ax, &Symbolic, NULL, NULL) ;
Comments?
The cast is not needed in C (but is in C++).
If the package was originally written before C had function prototypes,
then the sample usage (with arguments of type double *) was needed for
compilers that used different representations for pointers to different
types. With function prototypes, the compiler, if necessary, converts
arguments with a value of NULL to the null pointer of the type of the
corresponding function parameter.
.
- References:
- Question about (double *)NULL
- From: Rouben Rostamian
- Question about (double *)NULL
- Prev by Date: Re: How it works?
- Next by Date: Re: help me learn C
- Previous by thread: Re: Question about (double *)NULL
- Next by thread: Function Signatures In time.h
- Index(es):
Relevant Pages
|