From 5a5ff4250b9b267768137eb44486c52aac35bca8 Mon Sep 17 00:00:00 2001 From: Mislav Date: Mon, 12 Nov 2018 18:15:53 +0100 Subject: [PATCH 1/5] Exercise 01 --- .gitignore | 1 + example/01/p01.vcxproj | 2 + exercise/01/app/app.cpp | Bin 0 -> 1242 bytes exercise/01/app/app.vcxproj | 174 ++++++++++++++++++ exercise/01/app/app.vcxproj.filters | 30 +++ exercise/01/app/pch.cpp | Bin 0 -> 430 bytes exercise/01/app/pch.h | Bin 0 -> 1262 bytes exercise/01/dll1/dllmain.cpp | Bin 912 -> 818 bytes exercise/01/dll1/dynamic_library.cpp | Bin 230 -> 232 bytes exercise/01/dll1/dynamic_library.vcxproj | 4 +- .../dll2/dynamic_library_with_implib.vcxproj | 4 +- exercise/01/e01.sln | 25 +-- exercise/01/lib/fun.cpp | Bin 252 -> 262 bytes exercise/01/lib/public.h | Bin 166 -> 164 bytes exercise/01/lib/static_library.vcxproj | 4 +- 15 files changed, 223 insertions(+), 21 deletions(-) create mode 100644 exercise/01/app/app.cpp create mode 100644 exercise/01/app/app.vcxproj create mode 100644 exercise/01/app/app.vcxproj.filters create mode 100644 exercise/01/app/pch.cpp create mode 100644 exercise/01/app/pch.h diff --git a/.gitignore b/.gitignore index 4164f21..e3a747b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ *.ipdb *.iobj *.exp +.vs/ \ No newline at end of file diff --git a/example/01/p01.vcxproj b/example/01/p01.vcxproj index 71eeb22..37cfd07 100644 --- a/example/01/p01.vcxproj +++ b/example/01/p01.vcxproj @@ -172,6 +172,7 @@ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true pch.h + stdcpp17 Console @@ -202,6 +203,7 @@ _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true pch.h + stdcpp17 Console diff --git a/exercise/01/app/app.cpp b/exercise/01/app/app.cpp new file mode 100644 index 0000000000000000000000000000000000000000..61b27003b3738b38490ebdc3f78ba60b5aa2ef28 GIT binary patch literal 1242 zcmbW0OH0E*6ot=P@IQpOXev_CrA9&UvFSq4g$tpiNz_7Xi$;rxe_j3VOr{TOgvu~U z=H@=mIrq-j=avR~RIZ_3RH#&>SQE|<>ab&NYD23&DN$oRtI`uOnMOKp@QlgR(JuK1 z>hqpZr|(YrpA|w}f$vcJYec5HqlR&+9Lh)V4IA;LnmPpv_)KABted!`HDgokzV|CMTh)VXIsO{8vch87F8Hg$>L}+Y$A|0{2STZbKqWUPAvEPWk)|qa2Cg@*aF$N=i za`lK^^zGF7Vk)+E_)EPBIma&2Diy9@&+zaFF6dsR%i8B;$s?(A@8BE5*F1ZA1&hr} ziS74_L49ArW~9&oE7(Ii$H)reFBr_ImR7tcq)4=AyIz8u`J9ah~Da$mx0(r)^PDVdEY5#+# + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6} + Win32Proj + app + 10.0.17134.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ + + + false + + + false + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ + static_library.lib;dynamic_library_with_implib.lib;%(AdditionalDependencies) + + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ + static_library.lib;dynamic_library_with_implib.lib;%(AdditionalDependencies) + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + pch.h + + + Console + true + true + true + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/exercise/01/app/app.vcxproj.filters b/exercise/01/app/app.vcxproj.filters new file mode 100644 index 0000000..45e6ae5 --- /dev/null +++ b/exercise/01/app/app.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/exercise/01/app/pch.cpp b/exercise/01/app/pch.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a38f8a37da858b0e7a4a577210e923c883ac97f3 GIT binary patch literal 430 zcma)(OAdlS5JYQj;vFWsRoUwaJO;ubLXfO} ziM!*RK?b#&)PqF4LX~Q_GVq=g$>^{f<-{7@$r|ykmqm|MwtC_%l{t|TJS9Jpalvn} ztpC7C!Dg_+`-h+El+KlNtsDc|GOvyF+iK(A-j!r1ot!0T2mdlziM{46Ghg8k=#H+V zM?tLvNCnoo3Y&aHb%nm~4lL&e!^r!5 zY>)Yt7?F2lcmBR1+QK#-XGNr7XZ8fr!cn3lZ5^Y)vUSfD^AwDN*h^Lw&)lPx++47# zd)SAA*b{C}iSS;`84M~$v>AMrgP7FJ8+gu~LAukhS6*EOJ`b`OdG>3c0~t!sZmv>H zn*HLA@+(*ivq2}#QbRtnCS6sZB|bGHY13EaXpqYpyv1DpS76m1eTdT|r_t-78YQ1T z#<62u5HD*r_L~oQCI!E8@(t$Ve*GNp63pmTN&3$4QJrKBuD-fJIu~wfYrcy;aeoU( z{gpDyo!duDy%mVwzd3}ObITpQ?&R3*fD>2bk}TRUp!6E5gQ6*el=X_*#+Q5I8?Z>{ zRy|dAN-mZA&0pz!j#b}5FeyBGiKSg%o7_9|!S#V|#ttsxpDyDUbdaS$838tGos$-v9N#ZV0*C;w)2W`(d0GKo)4 kVp5xYj7eeg8YVFyZ3e_blZBYICc7|;u-1arr!uPp0DOQKuK)l5 delta 134 zcmdnQHi3P@BSwXZ4+D7>7+e^_8T=W7fV9G7YsSdQlNdE7voUJ%YclXMa4}SaNd=(X zQATH=Y6T>bjZEs3O_;p> diff --git a/exercise/01/dll1/dynamic_library.cpp b/exercise/01/dll1/dynamic_library.cpp index 7a2941899d92ced26526bc0c90eb01970acd6e3e..6386819df9a0e634505cbaf86ba4ac826b60a772 100644 GIT binary patch delta 13 UcmaFH_=0i57G?zog^61Y0VNy+&j0`b delta 11 ScmaFC_>6JF7DmpA+YJF7&IFhM diff --git a/exercise/01/dll1/dynamic_library.vcxproj b/exercise/01/dll1/dynamic_library.vcxproj index 7530308..0387866 100644 --- a/exercise/01/dll1/dynamic_library.vcxproj +++ b/exercise/01/dll1/dynamic_library.vcxproj @@ -72,12 +72,12 @@ true - $(Platform)\$(Configuration)\ + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ true - $(Platform)\$(Configuration)\ + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ false diff --git a/exercise/01/dll2/dynamic_library_with_implib.vcxproj b/exercise/01/dll2/dynamic_library_with_implib.vcxproj index 9ad2802..591ffd4 100644 --- a/exercise/01/dll2/dynamic_library_with_implib.vcxproj +++ b/exercise/01/dll2/dynamic_library_with_implib.vcxproj @@ -72,12 +72,12 @@ true - $(Platform)\$(Configuration)\ + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ true - $(Platform)\$(Configuration)\ + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ false diff --git a/exercise/01/e01.sln b/exercise/01/e01.sln index fb6ce37..67c040b 100644 --- a/exercise/01/e01.sln +++ b/exercise/01/e01.sln @@ -5,17 +5,12 @@ VisualStudioVersion = 15.0.28010.2036 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "static_library", "lib\static_library.vcxproj", "{990D865F-0DF2-40ED-8622-8DD0DB4A2128}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "app", "app\app.vcxproj", "{843D77A9-6E04-4515-91D5-A010A5CDF8E0}" - ProjectSection(ProjectDependencies) = postProject - {92DBD108-3D52-419D-BC33-217327A4AD9D} = {92DBD108-3D52-419D-BC33-217327A4AD9D} - {990D865F-0DF2-40ED-8622-8DD0DB4A2128} = {990D865F-0DF2-40ED-8622-8DD0DB4A2128} - {4EA09877-C87B-489E-9F80-A921D8E66E46} = {4EA09877-C87B-489E-9F80-A921D8E66E46} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dynamic_library", "dll1\dynamic_library.vcxproj", "{92DBD108-3D52-419D-BC33-217327A4AD9D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dynamic_library_with_implib", "dll2\dynamic_library_with_implib.vcxproj", "{4EA09877-C87B-489E-9F80-A921D8E66E46}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "app", "app\app.vcxproj", "{2338FE66-E92D-4026-AB7F-90C8A01F0BD6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -32,14 +27,6 @@ Global {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x64.Build.0 = Release|x64 {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x86.ActiveCfg = Release|Win32 {990D865F-0DF2-40ED-8622-8DD0DB4A2128}.Release|x86.Build.0 = Release|Win32 - {843D77A9-6E04-4515-91D5-A010A5CDF8E0}.Debug|x64.ActiveCfg = Debug|x64 - {843D77A9-6E04-4515-91D5-A010A5CDF8E0}.Debug|x64.Build.0 = Debug|x64 - {843D77A9-6E04-4515-91D5-A010A5CDF8E0}.Debug|x86.ActiveCfg = Debug|Win32 - {843D77A9-6E04-4515-91D5-A010A5CDF8E0}.Debug|x86.Build.0 = Debug|Win32 - {843D77A9-6E04-4515-91D5-A010A5CDF8E0}.Release|x64.ActiveCfg = Release|x64 - {843D77A9-6E04-4515-91D5-A010A5CDF8E0}.Release|x64.Build.0 = Release|x64 - {843D77A9-6E04-4515-91D5-A010A5CDF8E0}.Release|x86.ActiveCfg = Release|Win32 - {843D77A9-6E04-4515-91D5-A010A5CDF8E0}.Release|x86.Build.0 = Release|Win32 {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x64.ActiveCfg = Debug|x64 {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x64.Build.0 = Debug|x64 {92DBD108-3D52-419D-BC33-217327A4AD9D}.Debug|x86.ActiveCfg = Debug|Win32 @@ -56,6 +43,14 @@ Global {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x64.Build.0 = Release|x64 {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x86.ActiveCfg = Release|Win32 {4EA09877-C87B-489E-9F80-A921D8E66E46}.Release|x86.Build.0 = Release|Win32 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6}.Debug|x64.ActiveCfg = Debug|x64 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6}.Debug|x64.Build.0 = Debug|x64 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6}.Debug|x86.ActiveCfg = Debug|Win32 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6}.Debug|x86.Build.0 = Debug|Win32 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6}.Release|x64.ActiveCfg = Release|x64 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6}.Release|x64.Build.0 = Release|x64 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6}.Release|x86.ActiveCfg = Release|Win32 + {2338FE66-E92D-4026-AB7F-90C8A01F0BD6}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/exercise/01/lib/fun.cpp b/exercise/01/lib/fun.cpp index 0517472466cc890a161a3efed014255c40d58bd0..ee9087e6e1713e68821d286f58f8bb475ca4fa48 100644 GIT binary patch delta 43 qcmeyv*v2#=iCKX`VPdMaAdq6HX5eMu0@7eOak(}th*3N7x+(z5oCyH{ delta 33 lcmZo;`olOOiJ6yyYhtQ3do=@)!N56jqc&?Th&l10DgcZ>2m$~A diff --git a/exercise/01/lib/public.h b/exercise/01/lib/public.h index fc6a77d05674a4e3883a15c52037efbe11491d6f..0c47d662a56d892a542a944973da2f3f6912e04d 100644 GIT binary patch delta 13 UcmZ3+xP);+9J2z0!o+xI02`(Qu>b%7 delta 16 XcmZ3&xQuZ^93$t%L}wOW1}+8wC&B}j diff --git a/exercise/01/lib/static_library.vcxproj b/exercise/01/lib/static_library.vcxproj index 9e42fda..9f8d59b 100644 --- a/exercise/01/lib/static_library.vcxproj +++ b/exercise/01/lib/static_library.vcxproj @@ -72,12 +72,12 @@ true - $(Platform)\$(Configuration)\ + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ true - $(Platform)\$(Configuration)\ + $(SolutionDir)\Bin\$(Platform)\$(Configuration)\ false From f4f6f40d3190aa0b658e4ba6d0bdc3e53a287241 Mon Sep 17 00:00:00 2001 From: Mislav Date: Mon, 12 Nov 2018 18:27:57 +0100 Subject: [PATCH 2/5] Now works on all platforms --- exercise/01/app/app.cpp | Bin 1242 -> 1218 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/exercise/01/app/app.cpp b/exercise/01/app/app.cpp index 61b27003b3738b38490ebdc3f78ba60b5aa2ef28..8566f47db4a4507203e3a801bcaf35742351d540 100644 GIT binary patch delta 81 zcmcb`d5CjE1|w%OLq0^eD&r3C=H{THAB delta 117 zcmX@ad5d#H2IJ%s#)8Qo7>g$7F*WeVGsH6#Gn6o-FeEc1GUQDD%4BJ-z@PwRmjXre yfvhr+IFOeLWZMF<216Q8=fTpMx# From fec6d7968d31f3bea7953f08c216c3d463da45c2 Mon Sep 17 00:00:00 2001 From: Mislav Date: Tue, 13 Nov 2018 09:31:18 +0100 Subject: [PATCH 3/5] Minor cleanup of code --- exercise/01/app/app.cpp | Bin 1218 -> 1194 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/exercise/01/app/app.cpp b/exercise/01/app/app.cpp index 8566f47db4a4507203e3a801bcaf35742351d540..71ac416e6f9e97f808b2db01c3929d6d93567e50 100644 GIT binary patch delta 36 scmX@axr%cG3nOFrWLC!6jE<96GU_v0PmX7lpZtsQ1Ea>~pG+qi0m?QD+W-In delta 53 zcmZ3*d5CiZ3nOFsWLC!6oEi)v46Y0j3?Y*jGU{(W$0)?eufU+ekj#+6kP0Mo7!)=? IWID+R0AoT8ApigX From b49792eaabf08485da1333d7d9388d053ff6ce0e Mon Sep 17 00:00:00 2001 From: Mislav Date: Tue, 13 Nov 2018 10:57:44 +0100 Subject: [PATCH 4/5] Solution --- exercise/02/code.cpp | 16 ++++++++++++++++ exercise/02/code.h | 3 +++ exercise/02/test1.cpp | 6 +++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/exercise/02/code.cpp b/exercise/02/code.cpp index 85e778c..66d8527 100644 --- a/exercise/02/code.cpp +++ b/exercise/02/code.cpp @@ -1,2 +1,18 @@ #include "stdafx.h" #include "code.h" + +void f1(int& a, int& b) +{ + auto c = a; + a = b; + b = c; +} + +void f2(int* a, const int* b) +{ + while (a != b) + { + *a = *a + 1; + ++a; + } +} diff --git a/exercise/02/code.h b/exercise/02/code.h index e69de29..cc7f880 100644 --- a/exercise/02/code.h +++ b/exercise/02/code.h @@ -0,0 +1,3 @@ +void f1(int& a, int& b); + +void f2(int* a, const int* b); diff --git a/exercise/02/test1.cpp b/exercise/02/test1.cpp index 33dfab7..29b52ae 100644 --- a/exercise/02/test1.cpp +++ b/exercise/02/test1.cpp @@ -14,14 +14,14 @@ namespace simple_test TEST_METHOD(f1_changes_values) { int a=1, b=2; - //f1(a, b); + f1(a, b); Assert::AreEqual(2, a); Assert::AreEqual(1, b); } TEST_METHOD(f2_increases_all_values_by_one) { int arr[] = { 1, 2, 3 }; - //f2(arr, arr+3); + f2(arr, arr+3); Assert::AreEqual(2, arr[0]); Assert::AreEqual(3, arr[1]); Assert::AreEqual(4, arr[2]); @@ -29,7 +29,7 @@ namespace simple_test TEST_METHOD(f2_works_for_different_number_of_values) { int arr[] = { 2, 4, 6, 8, 10 }; - //f2(arr, arr+5); + f2(arr, arr+5); Assert::AreEqual(3, arr[0]); Assert::AreEqual(5, arr[1]); Assert::AreEqual(7, arr[2]); From 396a5aca2e78d74f6b9a507abf2d35fb5eca9c94 Mon Sep 17 00:00:00 2001 From: Mislav Date: Tue, 13 Nov 2018 11:05:38 +0100 Subject: [PATCH 5/5] while -> for --- exercise/02/code.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/exercise/02/code.cpp b/exercise/02/code.cpp index 66d8527..229d0e0 100644 --- a/exercise/02/code.cpp +++ b/exercise/02/code.cpp @@ -10,9 +10,5 @@ void f1(int& a, int& b) void f2(int* a, const int* b) { - while (a != b) - { - *a = *a + 1; - ++a; - } + for (; a != b; ++a) *a = *a + 1; }