Redefinition of function with namespace
zhc134 opened this issue · comments
Hi, in cling 0.7.0
, function redefinition is supported, which is great!
I can run the following cell and redefine function as many time as I want
int test(int x) {
return x+2;
}
However, if I specify namespace, an error will occur
namespace myname {
int test(int x) {
return x+2;
}
}
input_line_14:2:9: error: redefinition of 'test'
int test(int x) {
^
input_line_13:2:9: note: previous definition is here
int test(int x) {
^
Is there a way to work around this?
Also, I want to redefine system
function like
void system(const std::string &cmd) {
std::cout << "system: " << cmd << std::endl;
}
However, when I call system("123")
, I still get the original system
function.
Hello @zhc134,
Providing a new definition for a namespace member is not currently supported. In regards to redefining the system()
function, we are currently working on allowing this, but it still has some caveats. I will leave this issue open until it completely works.
Cheers,
J.
Works fine with current master. Please reopen if it still fails.
int test(int x) { return x+1; }
namespace myname { int test(int x) { return x+2; } }
test(1)
(int) 2
myname::test(1)
(int) 3
Also, I want to redefine
system
function like
Works fine with latest master if you choose the right signature:
extern int system( const char* command ) { std::cout << "system: " << std::endl; return 1; }
system("123");
system: