Thread: error: expression must have pointer-to-object type

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    3

    error: expression must have pointer-to-object type

    I have been working on a code using FFTW3 and i have gotten the program down to giving only one error: " error: expression must have pointer-to-object type" but multiple times.

    The parts giving me trouble are the pointers for fftw_complex, here is everywhere these pointers (fourier_u,fourier_v, and fourier_w) are referenced in my code:

    Code:
    fftw_complex *fourier_u,*fourier_v,*fourier_w;
    ...        
    fourier_u = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) *                DIM2 );
    fourier_v = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) * DIM2 );
    fourier_w = ( fftw_complex* ) fftw_malloc( sizeof( fftw_complex ) * DIM2 );
    ...
    l = 0;
        for(k=0;k<(nz/2)+1;k++)
            for(j=0;j<ny;j++)
                for(i=0;i<nx;i++)
                {
                    fur = (double)creal(vt[j][k][0]);
                    fui = (double)cimag(vt[j][k][0]);
                    fvr = (double)creal(vt[j][k][1]);
                    fvi = (double)cimag(vt[j][k][1]);
                    fwr = (double)creal(vt[j][k][2]);
                    fwi = (double)cimag(vt[j][k][2]);
                                    
                    fourier_u[l][0] = fur;
                    fourier_u[l][1] = fui;
                    fourier_v[l][0] = fvr;
                    fourier_v[l][1] = fvi;
                    fourier_w[l][0] = fwr;
                    fourier_w[l][1] = fwi;    
                        l++ 
                         }        
    ...
    I have tested the code and as expected, fur, fui,fvr,fvi,fwr,fwi are all of type double. I tried following an example but when I compile my program (using mpicc) I get the following error message for the last few lines of the portion of the code shown above:
    Code:
    FinalTurbulence.c(176): error: expression must have pointer-to-object type
                                    fourier_u[l][0] = fur;
                                    ^
    
    FinalTurbulence.c(177): error: expression must have pointer-to-object type
                                    fourier_u[l][1] = fui;
                                    ^
    
    FinalTurbulence.c(178): error: expression must have pointer-to-object type
                                    fourier_v[l][0] = fvr;
                                    ^
    
    FinalTurbulence.c(179): error: expression must have pointer-to-object type
                                    fourier_v[l][1] = fvi;
                                    ^
    
    FinalTurbulence.c(180): error: expression must have pointer-to-object type
                                    fourier_w[l][0] = fwr;
                                    ^
    
    FinalTurbulence.c(181): error: expression must have pointer-to-object type
                                    fourier_w[l][1] = fwi;
                                    ^
    I have searched extensively for a solution but have had no luck. Any help would be greatly appreciated. And I can provide more information if needed, but as stated above I included all of the code where the questionable pointers are used. Thanks.

  2. #2
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    How is the fftw_complex type defined? Since fur, fui, etc. are all doubles and you intend to store them in a two-dimensional array, you had better be 100% sure that fourier_u, fourier_v, etc. are all pointers to pointers to doubles.
    Code:
    while(!asleep) {
       sheep++;
    }

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    3
    From the FFTW3 manual, in the fftw3.h header fftw_complex is defined as:

    Code:
    The default FFTW interface uses double precision for all floating-point numbers, and defines a fftw_complex type to hold complex numbers as:
    
    
    typedef double fftw_complex[2];
    
    
    Here, the [0] element holds the real part and the [1] element holds the imaginary part.

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    3
    Also if it helps a working example of a code using the FFTW3 can be found at
    FFT with FFTW Example

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression must have a pointer type
    By ArunS in forum C Programming
    Replies: 2
    Last Post: 06-23-2011, 03:27 AM
  2. Noob Question regarding Pointer-to-Object type
    By Drysdale in forum C++ Programming
    Replies: 2
    Last Post: 11-21-2010, 02:45 AM
  3. Replies: 2
    Last Post: 11-25-2009, 07:38 AM
  4. Data type mismatch in criteria expression ERROR
    By Aga^^ in forum C# Programming
    Replies: 2
    Last Post: 02-11-2009, 01:21 AM
  5. Issues with expression must be a point to an object error:
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 02-22-2002, 04:14 PM