stuck, please help. I followed this but cannot fix it !! argh ! Why does a 1B (uint8_t) work, but the 4B int or uin16_t fail ?
error: invalid type argument of unary '*' (have 'int')
uint16_t current_frameLength =0;
uint16_t plc_tx_count = 0;
typedef struct
{
uint8_t Nsdu[R_DEMO_APP_NSDU_BUFFER_SIZE];
uint16_t position;
uint16_t frameLength;
} ota_buff_t;
typedef struct
{
//ota_buff_t (*buf_ptr)[]; //pointer to array of buf_ptr
ota_buff_t *buf_ptr; //pointer to array of buf_ptr
uint8_t buf_entry;
} ota_list_t;
ota_list_t ota_list;
ota_buff_t *rob_buf = malloc(sizeof(ota_buff_t)*5);
ota_list.buf_ptr = rob_buf; //enter the address of the buffer to the pointer
*(ota_list.buf_ptr[ota_list.buf_entry].Nsdu ) = 0xD0;
*(ota_list.buf_ptr[ota_list.buf_entry].Nsdu +1) = 0xD0;
*(ota_list.buf_ptr[ota_list.buf_entry].Nsdu +2) = plc_tx_count & 0x00FF;
*(ota_list.buf_ptr[ota_list.buf_entry].Nsdu +3) = plc_tx_count >>8; //POST auto-increment
*(ota_list.buf_ptr[ota_list.buf_entry].frameLength) = current_frameLength;
the only line that has a compile issue is the last, with assigning the contents of variable 'current_frameLength' to a defined uin16_t variable !!!
error: invalid type argument of unary '*' (have 'int')
frameLengthmember? Is it a pointer you can dereference? Is the problem because you copy-pasted a little too much?pand indexi, the expression*(p + i)is exactly equal top[i]. Please settle on using only one of those ways to get an element from an array. I suggest the array-index syntax. Inconsistent use of operators makes the code harder to read and understand. And using array-index syntax would also have helped you discover the copy-paste mistake you made much easier.frameLengthnorcurrent_frameLengthare pointers. They are actual values. You don't copy addresses or locations, you copy values.ota_list.buf_entryis uninitialized soota_list.buf_ptr[ota_list.buf_entry]invokes undefined behavior