B
BA
Hello all,
I need some help understand this ..
On Debian, using gcc :-
/* I have a structure defined as */
struct struImpl {
int unroll;
char *type;
void (*comp_func)(double *M, double *C);
void (*mvp_func)(double *C, double *X, double *Y);
}
/* Next I create an array of this struct as follows: */
struct struImpl Impls[] = {
{ 1, "CRS", compress2crs, mvp_crs },
{ 1, "CDS", compress2cds, mvp_cds }
};
/* also declare another function pointer */
void (*fptr)(double *, double *) = compress2crs;
printf(" Impls[0].comp_func = %x\n", Impls[0].comp_func); /* 1 */
printf(" compress2crs = %x\n", compress2crs); /* 2 */
printf(" fptr = %x\n", fptr); /* 3 */
now surprisingly,
/* 1 */ prints
Impls[0].comp_func = 8058d48
while /* 2 */ prints
compress2crs = 80497a8
and /* 3 */ prints
fptr = 80497a8
Any call made through fptr calls the correct function, while the
pointer in the structure does not seem to work.
Thank you,
I need some help understand this ..
On Debian, using gcc :-
/* I have a structure defined as */
struct struImpl {
int unroll;
char *type;
void (*comp_func)(double *M, double *C);
void (*mvp_func)(double *C, double *X, double *Y);
}
/* Next I create an array of this struct as follows: */
struct struImpl Impls[] = {
{ 1, "CRS", compress2crs, mvp_crs },
{ 1, "CDS", compress2cds, mvp_cds }
};
/* also declare another function pointer */
void (*fptr)(double *, double *) = compress2crs;
printf(" Impls[0].comp_func = %x\n", Impls[0].comp_func); /* 1 */
printf(" compress2crs = %x\n", compress2crs); /* 2 */
printf(" fptr = %x\n", fptr); /* 3 */
now surprisingly,
/* 1 */ prints
Impls[0].comp_func = 8058d48
while /* 2 */ prints
compress2crs = 80497a8
and /* 3 */ prints
fptr = 80497a8
Any call made through fptr calls the correct function, while the
pointer in the structure does not seem to work.
Thank you,