Skip to content

Commit

Permalink
* rename some classes
Browse files Browse the repository at this point in the history
* updated copyright
  • Loading branch information
glensand committed Feb 24, 2021
1 parent a516ce2 commit 2f00529
Show file tree
Hide file tree
Showing 26 changed files with 224 additions and 315 deletions.
16 changes: 16 additions & 0 deletions v110/export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Copyright (C) 2020 - 2021 Gleb Bezborodov - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the MIT license.
*
* You should have received a copy of the MIT license with
* this file. If not, please write to: [email protected], or visit : https://github.com/glensand/visual-studio-compatibility
*/

#pragma once

#ifdef MYDLL_EXPORTS
#define API __declspec(dllexport)
#else
/*Enabled as "import" in the Client side for using already created dll file*/
#define API __declspec(dllimport)
#endif
27 changes: 12 additions & 15 deletions vs2012/ExportClass.cpp → v110/export_class_110.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
#include "ExportClass.h"
#include "export_class_110.h"

#include <iostream>

ExportClass::ExportClass()
{
export_class_110::export_class_110() {

}


ExportClass::~ExportClass()
{
export_class_110::~export_class_110() {

}

ExportClass::StringList ExportClass::getStringList() const
{
StringList rValue;
export_class_110::string_list_t export_class_110::get_string_list() const {
string_list_t rValue;
rValue.emplace_back("test_string1");
rValue.emplace_back("ultra long test string for memory corruption");
rValue.emplace_back("ultimately long test string for memory corruption");
return rValue;
}

ExportClass* ExportClass::Create()
{
return new ExportClass();
export_class_110* export_class_110::create() {
return new export_class_110;
}

void ExportClass::Destroy(ExportClass* ptr)
{
void export_class_110::destroy(export_class_110* ptr) {
delete ptr;
}

void ExportClass::Fill(StringList& list)
{
void export_class_110::fill(string_list_t& list) {
list.emplace_back("test_string1");
list.emplace_back("ultra long test string for memory corruption");
list.emplace_back("ultimately long test string for memory corruption");
Expand Down
30 changes: 30 additions & 0 deletions v110/export_class_110.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright (C) 2020 - 2021 Gleb Bezborodov - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the MIT license.
*
* You should have received a copy of the MIT license with
* this file. If not, please write to: [email protected], or visit : https://github.com/glensand/visual-studio-compatibility
*/

#pragma once

#include "export.h"
#include <vector>
#include <string>

class API export_class_110 final
{
public:
typedef std::vector<std::string> string_list_t;
export_class_110();
~export_class_110();

string_list_t get_string_list() const;

static export_class_110* create();

static void destroy(export_class_110* ptr);

static void fill(string_list_t& list);
};

10 changes: 4 additions & 6 deletions vs2012/vs2012.vcxproj → v110/vs2012.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>vs2012</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>v110</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -43,6 +44,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
Expand Down Expand Up @@ -87,14 +89,10 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="export.h" />
<ClInclude Include="ExportClass.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="export_class_110.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ExportClass.cpp" />
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="vs2012.cpp" />
<ClCompile Include="export_class_110.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
25 changes: 25 additions & 0 deletions v110/vs2012.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="export">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="export.h">
<Filter>export</Filter>
</ClInclude>
<ClInclude Include="export_class_110.h">
<Filter>export</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="export_class_110.cpp">
<Filter>export</Filter>
</ClCompile>
</ItemGroup>
</Project>
16 changes: 16 additions & 0 deletions v141/export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Copyright (C) 2020 - 2021 Gleb Bezborodov - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the MIT license.
*
* You should have received a copy of the MIT license with
* this file. If not, please write to: [email protected], or visit : https://github.com/glensand/visual-studio-compatibility
*/

#pragma once

#ifdef MYDLL_EXPORTS
/*Enabled as "export" while compiling the dll project*/
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif
27 changes: 12 additions & 15 deletions vs2017dll/Exportedv141.cpp → v141/export_class_141.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
#include "Exportedv141.h"
#include "export_class_141.h"

#include <iostream>

Exportedv141::Exportedv141()
{
export_class_141::export_class_141() {

}


Exportedv141::~Exportedv141()
{
export_class_141::~export_class_141() {

}

Exportedv141::StringList Exportedv141::getStringList() const
{
StringList rValue;
export_class_141::string_list_t export_class_141::get_string_list() const {
string_list_t rValue;
rValue.emplace_back("test_string1");
rValue.emplace_back("ultra long test string for memory corruption");
rValue.emplace_back("ultimately long test string for memory corruption");
return rValue;
}

Exportedv141* Exportedv141::Create()
{
return new Exportedv141();
export_class_141* export_class_141::create() {
return new export_class_141();
}

void Exportedv141::Destroy(Exportedv141* ptr)
{
void export_class_141::destroy(export_class_141* ptr) {
delete ptr;
}

void Exportedv141::Fill(StringList& list)
{
void export_class_141::fill(string_list_t& list) {
list.emplace_back("test_string1");
list.emplace_back("ultra long test string for memory corruption");
list.emplace_back("ultimately long test string for memory corruption");
Expand Down
31 changes: 31 additions & 0 deletions v141/export_class_141.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Copyright (C) 2020 - 2021 Gleb Bezborodov - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the MIT license.
*
* You should have received a copy of the MIT license with
* this file. If not, please write to: [email protected], or visit : https://github.com/glensand/visual-studio-compatibility
*/

#pragma once

#include "export.h"
#include <vector>
#include <string>

class API export_class_141 final
{
public:
typedef std::vector<std::string> string_list_t;

export_class_141();
~export_class_141();

string_list_t get_string_list() const;

static export_class_141* create();

static void destroy(export_class_141* ptr);

static void fill(string_list_t& list);
};

20 changes: 11 additions & 9 deletions vs2017dll/vs2017dll.vcxproj → v141/vs2017dll.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="export.h" />
<ClInclude Include="export_class_141.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="export_class_141.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{87f599c0-ca46-41d3-a24f-3d34a80e6e84}</ProjectGuid>
<RootNamespace>vs2017dll</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
<ProjectName>v141</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -73,6 +81,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
Expand Down Expand Up @@ -116,7 +125,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MYDLL_EXPORTS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
Expand All @@ -140,13 +149,6 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="export.h" />
<ClInclude Include="Exportedv141.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Exportedv141.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
22 changes: 22 additions & 0 deletions v141/vs2017dll.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="export">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="export.h">
<Filter>export</Filter>
</ClInclude>
<ClInclude Include="export_class_141.h">
<Filter>export</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="export_class_141.cpp">
<Filter>export</Filter>
</ClCompile>
</ItemGroup>
</Project>
15 changes: 7 additions & 8 deletions vs2019/Source.cpp → v142/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "ExportClass.h"
#include "Exportedv141.h"
#include "v110/export_class_110.h"
#include "v141/export_class_141.h"

int main()
{
// stack object construction - destruction works well
ExportClass ec;
export_class_110 ec;

// we cannot deallocate memory were allocated in another module
// it seems like wrong dll loading
Expand All @@ -13,12 +13,11 @@ int main()
//ExportClass::Fill(testNotTrivialVector);

// also memory allocation and deallocation if it were done in single module works
auto exportClassPtr = ExportClass::Create();
delete exportClassPtr;
//ExportClass::Destroy(exportClassPtr);
auto* export_110 = export_class_110::create();
export_class_110::destroy(export_110);

auto vc141Exported = Exportedv141::Create();
delete vc141Exported;
auto* export_141 = export_class_141::create();
delete export_141;

return 0;
}
Loading

0 comments on commit 2f00529

Please sign in to comment.