1. I have an enum as follows
typedef enum my_thread_sched_mode_ {
MY_THREAD_MODE_NORMAL = 0,
MY_THREAD_MODE_NON_PREEMPTIVE = 0xffffffff,
} my_thread_sched_mode;
This generates code as
int _cffi_e_enum_my_thread_sched_mode_(char *out_error)
{
if (MY_THREAD_MODE_NORMAL != 0) {
snprintf(out_error, 255, "in enum %s: %s has the real value %d, not %d",
"my_thread_sched_mode_", "MY_THREAD_MODE_NORMAL", (int)MY_THREAD_MODE_NORMAL, 0);
return -1;
}
if (MY_THREAD_MODE_NON_PREEMPTIVE != 4294967295) {
snprintf(out_error, 255, "in enum %s: %s has the real value %d, not %d",
"my_thread_sched_mode_", "MY_THREAD_MODE_NON_PREEMPTIVE", (int)MY_THREAD_MODE_NON_PREEMPTIVE, 4294967295);
return -1;
}
return 0;
}
The second snprintf causes a warning
__pycache__/_cffi__g644663dbx82c763c2.c:910: warning: this decimal constant is unsigned only in ISO C90
__pycache__/_cffi__g644663dbx82c763c2.c:912: warning: this decimal constant is unsigned only in ISO C90
__pycache__/_cffi__g644663dbx82c763c2.c:912: warning: format '%d' expects type 'int', but argument 7 has type 'long unsigned int'
__pycache__/_cffi__g644663dbx82c763c2.c:912: warning: format '%d' expects type 'int', but argument 7 has type 'long unsigned int'
I am guessing this is caused by the 0xffffffff
Is this a limitation of some sort, can it be eliminated.
2. There is warnings such as
__pycache__/_cffi__g644663dbx82c763c2.c: In function '_cffi_f_my_dm_execute':
__pycache__/_cffi__g644663dbx82c763c2.c:619: warning: passing argument 2 of 'my_dm_execute' from incompatible pointer type
for code generated as follows
int _cffi_f_my_dm_execute(struct my_dm_handle_* x0, void(* x1)(struct my_dm_handle_* , long, uint64), long x2, uint64 *x3)
{
return my_dm_execute(x0, x1, x2, *x3);
}
From cdef as follows
typedef void (*my_dm_exec_handler)(my_dm_handle xdm, intptr_t data,
uint64 modifier);
int my_dm_execute(my_dm_handle xdm, my_dm_exec_handler h, intptr_t data,
uint64 modifier);
I can see that this has something to do with the way intptr_t and uint64 is being translated/defined in the generated code
and the way it is defined in the actual function definition in the library.
My question: What is the easy way to figure out what the right type should be.
I have tried generating the myfile.E files with the macro expansion done, but doesn't seem to be helping.
Any ideas.
sarvi