Question

I'm using NIOS II - Eclipse Here is a sample of my code I'm basically trying to call a function

struct DevDesc {

u32* mmio;

}

struct DevDesc dev_desc;

struct MemDesc mem_desc_g;//this structure is defined in another file

struct SysDesc sys_desc_g = {

.dd = &dev_desc,

.md = &mem_desc_g,

};

u32 power_mode_sleep (struct SysDesc *sd)

{

void * dev_addr = sd->dd->mmio;

//code
//code
//code

return 0;

}

and a few lines later I try to call it

int main()

{

power_mode_sleep((u32*)dev_addr);

}

When i try to build it throws up the error 'dev_addr' undeclared (first use in this function) and it points to the line

power_mode_sleep((u32*)dev_addr);

I tried to make the code brief, only putting what I thought was necessary. If anyone would like to see more details I would be happy to provide them.

Was it helpful?

Solution

The void * dev_addr = sd->dd->mmio; is restricted to the scope of the function power_mode_sleep (struct SysDesc *sd) Hence the error.

Also, you are passing (u32*)dev_addr as a parameter to power_mode_sleep. Whereas, it expects a parameter of type struct SysDesc *

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top