I have to use this code but 开发者_JS百科I get receive the following error:
error c2036'Complex_Z 'unknown size
typedef struct Complex_Z{
double r, i;
} ;
void update_projection_zprimme(struct Complex_Z *X, struct Complex_Z *Y, struct Complex_Z *Z,
int numCols, int maxCols, int blockSize, struct Complex_Z *rwork,
struct primme_params *primme) {
int j; /* Loop variable */
int count;
struct Complex_Z tpone = {+1.0e+00,+0.0e00};
struct Complex_Z tzero = {+0.0e+00,+0.0e00};
/* --------------------------------------------------------------------- */
/* Zero the work array to prevent floating point traps during all-reduce */
/* --------------------------------------------------------------------- */
for (j = 0; j < maxCols*blockSize; j++) {
rwork[j] = tzero; //error c2036'Complex_Z 'unknown size
}
Your code:
typedef struct Complex_Z{
double r, i;
} ;
coincidentally declares the type struct Complex_Z
, but doesn't give a name for the typedef
. Specifically, it does not make Complex_Z
into a synonym of struct Complex_Z
.
However, I don't see where the code is referring to just Complex_Z
- though the reported error message indicates that it probably was missing the struct
. Since the code is a fragment, I think there was a change between the time the compiler ran and the code was displayed to us.
I suspect that these pieces of code come from more than one source file, and your for loop occurs in a location where the definition of Complex_Z is not visible.
Because you declare typedef struct Complex_Z {}
which is invalid 'C'
it s/b:
typedef struct {
double r, i;
} Complex_Z;
and then reference struct Complex_Z
when you should be referencing Complex_Z
for example:
struct Complex_Z tpone = {+1.0e+00,+0.0e00};
struct Complex_Z tzero = {+0.0e+00,+0.0e00};
s/b
Complex_Z tpone = {+1.0e+00,+0.0e00};
Complex_Z tzero = {+0.0e+00,+0.0e00};
精彩评论