cclangarmcc

Keil compiler v5 to v.6


I'm forced to switch from ARMCC v5 to CLANG(v.6). Here is the problem.

I have some struct that includes a pointer to the function which gets as a parameter pointer to the same structure.

So I do

struct _some_struct_s;
typedef void (*callback_f)(struct _some_struct *p);
 
typedef struct {
  callback_f fn;
  int        x; 
} some_type_s;

// init function
void init_some_struct (some_struct *p, callback_f f) {
  p->fn = f;
  p->x = 0;
}

In another file I'm writing the callback() and calling init_some_struct()

some_type_s  my_struc;
void callback (some_type_s *p) {
  p->x++;
}
init_some_struct (&my_struc, callback);

I had no issues with compiler 5 but a warning with version 6.


warning: incompatible function pointer types passing 'void (some_struct_s *)' to parameter of type 'callback_f' (aka 'void (*)(struct _some_struct_s *)') [-Wincompatible-function-pointer-types]

What can I do to avoid having this warning?


Solution

  • @ John Bollinger Thank you. I resolved my issue.

    typedef struct _some_struct_s {
    ...
    }some_struct_s;
    

    Sorry for the inconvenience.