VC++速记


速记用到,怕忘的vc小知识。
条件编译
条件编译常见用在定义动态链接库时。
在源文件中定义为导出dllexport
在头文件中定义为导入dllimport
这样的头文件既可以用在链接库项目中,
也可以直接复制到引用项目中用。
Dll.h
#ifdef DLL_API
#else
#define DLL_API extern "C" _declspec(dllimport)
#endif

DLL_API  int _stdcall add( int a, int b);
DLL_API  int _stdcall subtract( int a, int b);
Dll.cpp
#define DLL_API extern "C" _declspec(dllexport)
#include  " Dll.h "
#include <Windows.h>
#include <stdio.h>

int _stdcall add( int a, int b)
{
     return a+b;
}

int _stdcall subtract( int a, int b)
{
     return a-b;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM