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