会員の皆様、こんにちは。
今日、非常に奇妙な問題に遭遇しましたが、何が原因なのか正確にはわかりません。現在の作業ディレクトリを取得するために使用する関数は次のとおりです。
#ifdef _WIN32
#include <direct.h>
#define GetCurrentDir _getcwd
#else
#error "There is currently no support for non windows based systems!"
#endif
const std::string getCurrentPath()
{
char CurrentPath{_MAX_PATH];
GetCurrentDir(CurrentPath, _MAX_PATH);
CurrentPath[_MAX_PATH - 1] = '/0';
return std::string(CurrentPath);
}
この機能は、スタンドアロン機能として適切に機能します。ただし、クラス内で静的関数として宣言すると:
static __declspec(dllexport) const std::string getCurrentPath(void);
および.dllを実行しようとすると、「デバッグアサーション失敗エラー」が表示されます
std::cout<<CUtilities::getCurrentPath()<<std::endl;
代わりに次のように書くと:
std::string dir = CUtilities::getCurrentPath();
std::cout<<"Dir is : "<<dir<<std::endl;
それは正常に動作します。私は自分が間違っていることについて完全に混乱しています。何か案は?