よく使う自作関数をDLL化して様々なプロジェクトで使いまわそうと思ったのですが、
描画系の関数を呼ぶと例外が発生します。
■ testLib.h ■
#pragma once
#ifdef TESTLIB_EXPORTS
#define TESTLIB_API __declspec(dllexport)
#else
#define TESTLIB_API __declspec(dllimport)
#endif
namespace testLib
{
extern "C" TESTLIB_API void DrawExBox( int x, int y );
}
■ testLib.cpp ■
#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier
#include <DxLib.h>
#include "testLib.h"
namespace testLib
{
void DrawExBox( int x, int y )
{
DxLib::DrawBox( x, y, x + 10, y + 10, 0xff0000, true );
}
}
DxLib::DrawBoxを呼んだ時に以下の例外が発生
> 0x7922459B (testLib.dll) で例外がスローされました (testProject.exe 内): 0xC0000005: 場所 0x00000014 の読み取り中にアクセス違反が発生しました
描画系の関数はDLLから呼ぶことができないのでしょうか?
ちなみにほかのDXLIB関数( 試したのはDxLib::ErrorLogFmtAdd )は問題なく動きました。
Dxlibを使うためのプロジェクト設定は設定済みです。