Hi,
I want to get a pointer to a list of data that should be a list of arguments.
These are header stuff:
Code:
////////////////////////////////////////////////////////////////////////////////////////// enumerations
typedef enum {NOT_FINISHED,FINISHED,DONE}STATE;
// variables
typedef void (*f_ptr)(void *args);
// structs
typedef struct __attribute__((__packed__)) THREAD{
uint8_t tsk_cnts, tsk_cntr;
STATE thrd_st, *tsk_st;
f_ptr *fptr;
}THREAD;
typedef struct __attribute__((__packed__)) fptr_args{
uint8_t arg_n;
struct fptr_args *arg_list;
}tsk_args;
main.c:
Code:
#include "task_manager.h"#include "../sensors_modules/sensors_modules.h"
tsk_args lcd_args;
const unsigned char PIC[] = {0,9,8};
int main(){
lcd_args.arg_n = 4;
lcd_args.arg_list = malloc(3*sizeof(uint8_t)+1*sizeof(unsigned char*));
*(uint8_t*)(lcd_args.arg_list+0) = 20;
*(uint8_t*)(lcd_args.arg_list+1) = 90;
*(uint8_t*)(lcd_args.arg_list+2) = 80;
(uint64_t*)(lcd_args.arg_list+3) = &PIC; // error
The error is:
Code:
error: lvalue required as left operand of assignment
What I'm understanding here is that I'm dereferencing index 0, 1, 2 and assigning the address of the array to index 3 that shouldn't be dereferenced.
What should I do ?