S
Sandy
Hi,
I have two files as folllows
file1.cpp
#include<iostream>
using namespace std;
namespace {
void show();
void fun() { cout<<"fun called\n"; }
}
int main()
{
show();
return 0;
}
file2.cpp
#include<iostream>
using namespace std;
namespace{
void fun();
void show(){
fun();
cout<<"show called\n";
}
}
While trying to run this the linker is giving following message
Undefined first referenced
symbol in file
(anonymous namespace)::fun() file2.o
(anonymous namespace)::show() file1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
As far as i think, it should be able to find the definitions because
everything here belongs to a single "un-named" namespace.
Then why am i getting the problem?
I have two files as folllows
file1.cpp
#include<iostream>
using namespace std;
namespace {
void show();
void fun() { cout<<"fun called\n"; }
}
int main()
{
show();
return 0;
}
file2.cpp
#include<iostream>
using namespace std;
namespace{
void fun();
void show(){
fun();
cout<<"show called\n";
}
}
While trying to run this the linker is giving following message
Undefined first referenced
symbol in file
(anonymous namespace)::fun() file2.o
(anonymous namespace)::show() file1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
As far as i think, it should be able to find the definitions because
everything here belongs to a single "un-named" namespace.
Then why am i getting the problem?