tags:

views:

112

answers:

3

I have to use this code but 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
   }
A: 

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.

Darron
now i know the reason of the error i have this Warning warning C4627: '#include "complex .h"': skipped when looking for precompiled header use so it can not see the header file in the source code any help in this warning
basma osman
@basma: Move the `#include "stdafx.h"` line so it is the first of the `#include` lines.
Bart van Ingen Schenau
So, I have the most correct answer here (without knowing the particular environment, and specifics of precompiled headers), yet I get downvoted.
Darron
A: 

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};
KevinDTimm
This is not C++ (but your comments are accurate for C++, and inaccurate for C).
Jonathan Leffler
Fixed with the edit
KevinDTimm
A: 

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.

Jonathan Leffler