I want to call a static function from another C file. But it always show \"function\" used but never defined
.
In ble.c
Static function has internal linkage and it can be called only by functions written in the same file. However if you want to call static function from another file , we have a trick in C. Fallow the steps. 1. Create a function pointer globally in ble.c and define it.
(void)(*fn_ptr)();
static void bt_le_start_notification(void)
{
WPRINT_BT_APP_INFO(("bt_le_start_notification\n"));
fn_ptr=bt_le_start_notification;
}
in main.c extern the function pointer
#include "ble.h"
extern fn_ptr;
void application_start( void )
{
fn_ptr();
}
Hope it will be useful.