티스토리 뷰
Swap.h 소스
#ifndef __SWAP_H__
#define __SWAP_H__
#ifdef __cplusplus
#ifndef __SWAP_H__
#define __SWAP_H__
#ifdef __cplusplus
extern "C"
{
#endif{
#ifdef _COMPLING_DLL_SWAP
#define __declspec(dllexport)
#else#define __declspec(dllimport)
#endifvoid swap(int* v1, int* v2);
#ifdef __cplusplus
}
#endif
#endif
SwapDll.cpp 소스
#include "Swap.h"
void swap(int* v1, int* v2)
{
#endif
SwapDll.cpp 소스
#include "Swap.h"
void swap(int* v1, int* v2)
{
int temp = *v1;
*v1 = *v2;
*v2 = temp;
*v1 = *v2;
*v2 = temp;
}
DllTest.cpp 소스
#include <stdio.h>
#include <tchar.h>
#include "swap.h"
#pragma comment(lib, "Swap.lib");
int _tmain(int argc, TCHAR* argv[])
{
DllTest.cpp 소스
#include <stdio.h>
#include <tchar.h>
#include "swap.h"
#pragma comment(lib, "Swap.lib");
int _tmain(int argc, TCHAR* argv[])
{
int a = 10;
int b = 20;
_tprintf(_T("변경 전 : %d, &d\n"), a, b);
swap(a, b);
_tprintf(_T("변경 후 : %d, &d\n"), a, b);
return 0;
int b = 20;
_tprintf(_T("변경 전 : %d, &d\n"), a, b);
swap(a, b);
_tprintf(_T("변경 후 : %d, &d\n"), a, b);
return 0;
}
파일 확장자를 C 로 변경해도 실행 결과는 동일하다.
파일 확장자를 C 로 변경해도 실행 결과는 동일하다.