LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   error: dereferencing pointer to incomplete type (https://www.linuxquestions.org/questions/programming-9/error-dereferencing-pointer-to-incomplete-type-4175477574/)

answerme 09-18-2013 04:56 AM

error: dereferencing pointer to incomplete type
 
Hi All
I got an eval board MPC8641
I want to access one register for that


Code:

yy.c
unsigned long __iomem *devdisr;

devdisr=ioremap(get_immrbase() + 0xE0070,0x100);
        if(!devdisr) {
                return -ENOMEM;
        }

out_be32(devdisr,0x3000000);
reg_value=in_be32(devdisr);
printk(KERN_INFO " devdisr reg_value:  0x%x  \r\n",reg_value);

Here above Iam getting output BUT when I am accessing with structure I am getting error

Code:

xx.h file
typedef struct ccsr_guts {
        uint        devdisr;
} ccsr_guts_t;

Code:

yy.c file

struct  ccsr_guts __iomem *gur;
reg_value=in_be32(&gur->devdisr);

Iam getting error error: dereferencing pointer to incomplete type
Dont know how to resolve this problem

a4z 09-18-2013 05:00 AM

try changing
reg_value=in_be32(&gur->devdisr);
to
reg_value=in_be32(gur->devdisr);
since gur is already a pointer and taking the address of it might not be good

NevemTeve 09-18-2013 05:19 AM

add this line to yy.c:

Code:

#include "xx.h"
Also you should edit xx.h:

Code:

typedef struct ccsr_guts {
        uint        devdisr;
} ccsr_guts;

meaning: don't use two names for one thing.

answerme 09-18-2013 05:34 AM

I have tried it already above 2 solution which NevemTeve & a4z has given but still same problem existing

& its not ccsr_guts its ccsr_guts_t if see above again .ANY OTHER SOLUTIONS

NevemTeve 09-18-2013 05:45 AM

quote more code. example:

xx.h
Code:

/* xx.h */

#ifndef xx_h
#define xx_h

typedef struct ccsr_guts {
    unsigned devdisr;
} ccsr_guts;

#endif

yy.c
Code:

/* yy.c */

#include <stdio.h>

#include "xx.h"

int main (void)
{
    struct ccsr_guts gur;
    struct ccsr_guts *gurp= &gur;

    printf ("&gur->devdisr=%p\n", &gurp->devdisr);
    return 0;
}



All times are GMT -5. The time now is 08:34 PM.