The function is declared. There is a task to call this function by adding a pointer to it on the PIC16F66 controller stack. But, if the function is not called in the code, then the value of the function pointer is = 0. How to force the compiler to assign a value to a function pointer that is not called anywhere in the project?

  • environment MPLAB 4.15 compiler xc8 1.45 - Max Katrenko
  • It is very dependent on the compiler. If the function is not used, the compiler throws it out. Such optimization. Usually, when assigning a pointer to it explicitly, the compiler no longer throws the function. - kisssko 4:04 pm
  • @kisssko, from the linker, not the compiler. To the author: see how the EXPORT_SYMBOL() macro is implemented in the Linux kernel. He's just doing the trick. - 0andriy

0