About FunctionPointer

Hi ROOTers, I encounter a problem when using [color=red]FunctionPointer[/color].

I have 2 files.
the file “fun.c” define a [color=red]FunctionPointer[/color] and a function which uses the [color=red]FunctionPointer[/color].
the file “main.c” initial the [color=red]FunctionPointer[/color] and execute the function in “fun.c” by “.x main.c”

the code is as follow:

  1. in "fun.c"
    void color=blue();[/color] //define a [color=red]FunctionPointer[/color]
    void display() //a function using the [color=red]FunctionPointer[/color]

2.in “main.c”
#include"fun_c.dll" //“fun.c” is compiled and included
void m1()
void main()
[color=blue]m[/color]=m1; //initial the [color=red]FunctionPointer[/color]
[color=blue]m(); [/color] //execute the [color=red]FunctionPointer[/color] directly is OK
display(); //use the function in “fun.c” to execute [color=red]FunctionPointer[/color] is error

if “fun.c” is not compiled and use directly, there is no error.

so what should i do if i want to use [color=red]FunctionPointer[/color] in a compiled file?

Thanks :slight_smile:


can you try to add the declaration

extern void (*m)(); void display();
at the top of main.c? Or #include fun.h, i.e. move the declarations shared between func.c and main.c into a header file.

Cheers, Axel.