Article ID: 140357
Article Last Modified on 7/5/2005
/test1.cpp
/* Compile options needed: -W4
*/
namespace A{
extern "C" void printf(int);
}
void main(){
A::printf(1); // actually resolves to CRT printf
// which causes an access violation
}
//end of test1.cpp
//test2.cpp
/* Compile options needed: -W4
*/
#include <iostream.h>
namespace A{
extern "C" void function(void){cout <<"namespace A" <<endl;};
}
namespace B{
extern "C" void function(void){cout <<"namespace B" <<endl;};
}
void main(){
A::function();
B::function();
}
// end of test2.cpp
The compiler names both the functions as just "_function" resulting in
the following link errors:
-or-
Additional query words: 10.00 10.10 LNK2005 LNK1169
Keywords: kbbug kbcompiler kbcpponly kbprogramming KB140357