calbet
September 5, 2016, 12:15pm
1
Dear experts,
I have my root macro [1], and I have a file.cc in which I have several function [2]. As I have several
function in my file.cc , I wonder how to call them in the root macro, indeed using “myfunc();” in [3] give me the error message[4]. Do you know what is wrong?
Regards
[4]
error: use of undeclared identifier ‘myfunc’
[3] root.cc
#include "myfunc.cc "
void root(){
myfunc();
cout<<max();
}
[2] myfunc.cc
double max(){
…
}
bool pass(){
…
}
[1] root.cc
#include "myfunc.cc "
void root(){
cout<<max();
}
You do not define “myfunc()” anywhere.
calbet
September 5, 2016, 1:09pm
3
Dear pepe,
yes I used “myfunc();” in [1], but I got the error message in [2]:
Do you know what is wrong?
Regards
[2]
error: use of undeclared identifier ‘myfunc’
[1] root.cc
#include “myfunc.cc ” //include func.cc here!!
void root(){
myfunc(); //call func here!!
cout<<max();
}
Where it the definition:
myfunc() {
std::cout << “… myfunc called …” << std::endl;
}
calbet
September 5, 2016, 1:41pm
5
Dear pepe,
may I explain again. In myfunc.cc , I have several functions [1] (I actually want to put all my functions in a single file). Now, how can I call one of them in a root macro?
Regards
[2] root.cc
#include "myfunc.cc "
void root(){
//how to call func1() from myfunc.cc
}
[1] myfunc.cc
double func1(){ … }
double func2(){ … }
…
Use simply (“root.cc ”):
#include "myfunc.cc "
void root() {
double x, y;
x = func1();
y = func2();
std::cout << "x = " << x << " and y = " << y << std::endl;
}
Then:
root [0] .x root.cc
or:
root [0] .L root.cc
root [1] root()
or:
root -q -l root.cc
calbet
September 5, 2016, 2:05pm
7
Yes, but when I do that I have:
error: use of undeclared identifier 'myfunc’
myfunc();
Do you know what is wrong? I have ROOT 6.06/01
Regards
calbet
September 5, 2016, 2:22pm
8
Dear pepe,
for some reason it’s working now (the way you advised)… Thank you very much for your help.
Regards