From 587d648e43caf67025ea011c17552059b5c28483 Mon Sep 17 00:00:00 2001 From: glensand Date: Wed, 28 Jul 2021 18:02:13 +0700 Subject: [PATCH] added static linkage test v110 -> v142 --- v110/base_class_110.cpp | 8 +- v110/base_class_110.h | 15 ++- v110_static/class_110.cpp | 21 ++++ v110_static/class_110.h | 31 +++++ v110_static/v110_static.vcxproj | 151 ++++++++++++++++++++++++ v110_static/v110_static.vcxproj.filters | 19 +++ v110_static/v110_static.vcxproj.user | 4 + v142/main.cpp | 9 +- v142/vs2019.vcxproj | 4 +- vs2019.sln | 11 ++ 10 files changed, 262 insertions(+), 11 deletions(-) create mode 100644 v110_static/class_110.cpp create mode 100644 v110_static/class_110.h create mode 100644 v110_static/v110_static.vcxproj create mode 100644 v110_static/v110_static.vcxproj.filters create mode 100644 v110_static/v110_static.vcxproj.user diff --git a/v110/base_class_110.cpp b/v110/base_class_110.cpp index b435c69..ed9bef0 100644 --- a/v110/base_class_110.cpp +++ b/v110/base_class_110.cpp @@ -6,10 +6,10 @@ base_class_110::base_class_110() { vec.push_back(str); } -base_class_110::~base_class_110() { - for (auto&& f : fun) - f(); -} +//base_class_110::~base_class_110() { +// for (auto&& f : fun) +// f(); +//} void base_class_110::add_fun(const std::function& f) { fun.push_back(f); diff --git a/v110/base_class_110.h b/v110/base_class_110.h index 26f8013..ad715f9 100644 --- a/v110/base_class_110.h +++ b/v110/base_class_110.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 - 2021 Gleb Bezborodov - All Rights Reserved +/* Copyright (C) 2021 Gleb Bezborodov - All Rights Reserved * You may use, distribute and modify this code under the * terms of the MIT license. * @@ -13,10 +13,19 @@ #include #include -class base_class_110 { +class ref_counted { +public: + virtual ~ref_counted() {} +}; + +class base_class_110 : public ref_counted { public: API base_class_110(); - virtual API ~base_class_110(); + + virtual API ~base_class_110() { + for (auto&& f : fun) + f(); + } void API add_fun(const std::function& f); protected: diff --git a/v110_static/class_110.cpp b/v110_static/class_110.cpp new file mode 100644 index 0000000..fdc757d --- /dev/null +++ b/v110_static/class_110.cpp @@ -0,0 +1,21 @@ +#include "class_110.h" + +string::string(const char* _c): c(_c) +{ + +} + +class_110::class_110() +{ + +} + +void class_110::add_string(const string& _s) +{ + s = _s; +} + +void class_110::do_something() +{ + +} diff --git a/v110_static/class_110.h b/v110_static/class_110.h new file mode 100644 index 0000000..9e9975f --- /dev/null +++ b/v110_static/class_110.h @@ -0,0 +1,31 @@ +/* Copyright (C) 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: bezborodoff.gleb@gmail.com, or visit : https://github.com/glensand/visual-studio-compatibility + */ + +#pragma once + +class string final +{ +public: + string(const char* _c = nullptr); + +private: + const char* c; +}; + +class class_110 final +{ +public: + class_110(); + + void add_string(const string& _s); + void do_something(); + +private: + string s; +}; + diff --git a/v110_static/v110_static.vcxproj b/v110_static/v110_static.vcxproj new file mode 100644 index 0000000..1014d60 --- /dev/null +++ b/v110_static/v110_static.vcxproj @@ -0,0 +1,151 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {19185f72-6cbb-42db-8b65-c6dcc58aeeb6} + v110static + 10.0 + + + + StaticLibrary + true + v110 + Unicode + + + StaticLibrary + false + v110 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(Platform)\$(Configuration)\ + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/v110_static/v110_static.vcxproj.filters b/v110_static/v110_static.vcxproj.filters new file mode 100644 index 0000000..41a8f44 --- /dev/null +++ b/v110_static/v110_static.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + + + src + + + + + src + + + \ No newline at end of file diff --git a/v110_static/v110_static.vcxproj.user b/v110_static/v110_static.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/v110_static/v110_static.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/v142/main.cpp b/v142/main.cpp index 29d4920..769951a 100644 --- a/v142/main.cpp +++ b/v142/main.cpp @@ -1,7 +1,7 @@ #include "v110/export_class_110.h" #include "v141/export_class_141.h" #include "v142/derived_class_142.h" - +#include "v110_static/class_110.h" int main() { // stack object construction - destruction works well @@ -20,7 +20,12 @@ int main() auto* export_141 = export_class_141::create(); delete export_141; - derived_class_142 instance; + ref_counted* d_c = new derived_class_142; + delete d_c; + + class_110 static_class; + static_class.do_something(); + static_class.add_string("asfsadgdg"); return 0; } \ No newline at end of file diff --git a/v142/vs2019.vcxproj b/v142/vs2019.vcxproj index 743632e..b9f6f68 100644 --- a/v142/vs2019.vcxproj +++ b/v142/vs2019.vcxproj @@ -104,7 +104,7 @@ Console true $(SolutionDir)\$(Platform)\$(Configuration) - v110.lib;v141.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + v110_static.lib;v110.lib;v141.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) @@ -138,7 +138,7 @@ true true $(SolutionDir)\$(Platform)\$(Configuration) - v110.lib;v141.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + v110_static.lib;v110.lib;v141.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) diff --git a/vs2019.sln b/vs2019.sln index 90d6a4f..ce942ad 100644 --- a/vs2019.sln +++ b/vs2019.sln @@ -10,9 +10,12 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v142", "v142\vs2019.vcxproj", "{8177FFC6-CF66-44B6-963C-71F98CFA21D8}" ProjectSection(ProjectDependencies) = postProject {3C93CB41-FF1D-496A-8EB7-C8D774F2703D} = {3C93CB41-FF1D-496A-8EB7-C8D774F2703D} + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6} = {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6} {87F599C0-CA46-41D3-A24F-3D34A80E6E84} = {87F599C0-CA46-41D3-A24F-3D34A80E6E84} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v110_static", "v110_static\v110_static.vcxproj", "{19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -43,6 +46,14 @@ Global {8177FFC6-CF66-44B6-963C-71F98CFA21D8}.Release|x64.Build.0 = Release|x64 {8177FFC6-CF66-44B6-963C-71F98CFA21D8}.Release|x86.ActiveCfg = Release|Win32 {8177FFC6-CF66-44B6-963C-71F98CFA21D8}.Release|x86.Build.0 = Release|Win32 + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Debug|x64.ActiveCfg = Debug|x64 + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Debug|x64.Build.0 = Debug|x64 + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Debug|x86.ActiveCfg = Debug|Win32 + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Debug|x86.Build.0 = Debug|Win32 + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Release|x64.ActiveCfg = Release|x64 + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Release|x64.Build.0 = Release|x64 + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Release|x86.ActiveCfg = Release|Win32 + {19185F72-6CBB-42DB-8B65-C6DCC58AEEB6}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE