Post Go back to editing

pragma pure and const with function pointers in blackifin+ compiler


in blackfin+ code I am calling a function using a function pointer.

Is there a way to tell the compiler that any function assigned to the function pointer will be pure?

According to the documentation the pure pragma only woks at function definition not at the caller.

I.e would somehing like the follwing work?

void func(void);

#pragme pure

void (*myfuction)(int param);  //does the compiler recognize that  *myfuction will always be a pure function?

void func(void)


//some code...

(*myfunction)(param)  //this is a pure function: any function assigned to myfunction is guaranteed to be pure

// some cother code


  • You are correct that "pragma pure" (and also "pragma const") can't be used on function pointers - they are only valid for functions. I have logged a bug report for this, but I'm unable to say when (or if) this will be addressed. In the meantime, we will update the documentation for these pragmas so that the limitation is explained.