I have a set of functions for performing unsigned modular multiplication over large integers. For some reason, when I use my generic remainder function in the multiplication, the compiler (I'm using Clang with -Wall -Wextra
warning flags) gives incompatible pointer warning.
Header:
typedef struct {
uint32_t c;
uint32_t v[];
} vlong_t; // generic incomplete type.
vlong_t *vlong_remv_inplace(vlong_t *rem, const vlong_t *b);
typedef void *(*vlong_modfunc_t)(
vlong_t *restrict v,
void *restrict ctx);
vlong_t *vlong_mulv(
vlong_t *restrict out,
const vlong_t *a,
const vlong_t *b,
vlong_modfunc_t modfunc,
void *restrict mod_ctx);
Test code section that's giving the warning:
vlong_mulv(x, a, b, vlong_remv_inplace, b);
I've simplified the code a bit to create a minimal working example, my coding style have different variable naming conventions among others.
The warning is as follow:
vlong-test.c:85:20: warning: incompatible pointer types passing 'vlong_t *(vlong_t *, const vlong_t *)' to parameter of type 'vlong_modfunc_t'
(aka 'void *(*)(vlong_t *restrict, void *restrict)') [-Wincompatible-pointer-types]
vlong_mulv(x, a, b, vlong_remv_inplace, b);
^~~~~~~~~~~~~~~~~~
What rule am I breaking here?
question from:
https://stackoverflow.com/questions/65652186/two-supposedly-compatible-function-pointer-types-is-being-warned-as-incompatible 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…