conversion to non-scalar type requested
Hi,
When i compile a code snippet , i receive one error... error: conversion to non-scalar type requested Code: /* DDR Config3 register */ typedef struct config3 { uint32 cfg_startup_delay:17; uint32 reserved:15; }ddr_config3; void main() { ddr_config3 ddrconfig3; ddrconfig3 = (ddr_config3 )ddr2_reg_read ((uint32)DDR_CONFIG3); ..... ..... ..... } static inline uint32 ddr2_reg_read (uint32 reg) { volatile uint32 *reg_addr = (uint32 *) (DDR2_BASE + reg); return *reg_addr; } the error was in ddrconfig3 = (ddr_config3 )ddr2_reg_read ((uint32)DDR_CONFIG3); Thanks |
You're trying to convert the (scalar) value returned by ddr2_reg_read to a struct, and the compiler is telling you that it doesn't "know' how to do that.
I suspect that your intention was either to set one component or the structure to the value returned, or to have the function return a structure. (In the later case, you would not need the cast.) |
You are trying to convert an uint32 (an integer that's 32 bit in length, I suppose) to a structure containing two uint32.
What do you expect the compiler to do with that? I would do exactly like him: complain that it can't. |
All times are GMT -5. The time now is 06:19 PM. |