如何使得函数用namespace 封装 到lib,再在外部调用?
1.libT.cpp
#include <stdio.h>
namespace SystemCmd
{
void Test()
{
printf("sdfsf111");
}
}
2.生成libT.lib
>cl /c libT.cpp
>lib libT.obj
3.test.cpp 调用
#include <stdio.h>
#pragma comment(lib, "libT.lib")
namespace SystemCmd{
void Test();
}
/*
或
namespace SystemCmd{
#pragma comment(lib, "libT.lib")
void Test();
}
*/
void main()
{
SystemCmd::Test();
getchar();
}
4.生成exe+调试
>cl test.cpp
>test.exe