Skip to content

Commit f7e6b8d

Browse files
committed
Add How C++ Linker Works
1 parent 1632e7e commit f7e6b8d

File tree

7 files changed

+27
-23
lines changed

7 files changed

+27
-23
lines changed

HelloWorld/EndBrace.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

HelloWorld/HelloWorld.vcxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@
7878
<ConformanceMode>true</ConformanceMode>
7979
<PreprocessToFile>false</PreprocessToFile>
8080
<AssemblerOutput>AssemblyCode</AssemblerOutput>
81-
<Optimization>MaxSpeed</Optimization>
81+
<Optimization>Disabled</Optimization>
8282
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
83+
<LanguageStandard>stdcpp20</LanguageStandard>
84+
<LanguageStandard_C>stdc17</LanguageStandard_C>
8385
</ClCompile>
8486
<Link>
8587
<SubSystem>Console</SubSystem>
@@ -96,6 +98,9 @@
9698
<ConformanceMode>true</ConformanceMode>
9799
<PreprocessToFile>false</PreprocessToFile>
98100
<AssemblerOutput>AssemblyCode</AssemblerOutput>
101+
<Optimization>Disabled</Optimization>
102+
<LanguageStandard>stdcpp20</LanguageStandard>
103+
<LanguageStandard_C>stdc17</LanguageStandard_C>
99104
</ClCompile>
100105
<Link>
101106
<SubSystem>Console</SubSystem>
@@ -134,11 +139,10 @@
134139
</ItemDefinitionGroup>
135140
<ItemGroup>
136141
<ClCompile Include="Log.cpp" />
137-
<ClCompile Include="Main.cpp" />
138142
<ClCompile Include="Math.cpp" />
139143
</ItemGroup>
140144
<ItemGroup>
141-
<ClInclude Include="EndBrace.h" />
145+
<ClInclude Include="Log.h" />
142146
</ItemGroup>
143147
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
144148
<ImportGroup Label="ExtensionTargets">

HelloWorld/HelloWorld.vcxproj.filters

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,15 @@
1515
</Filter>
1616
</ItemGroup>
1717
<ItemGroup>
18-
<ClCompile Include="Main.cpp">
18+
<ClCompile Include="Math.cpp">
1919
<Filter>Fichiers sources</Filter>
2020
</ClCompile>
2121
<ClCompile Include="Log.cpp">
2222
<Filter>Fichiers sources</Filter>
2323
</ClCompile>
24-
<ClCompile Include="Math.cpp">
25-
<Filter>Fichiers sources</Filter>
26-
</ClCompile>
2724
</ItemGroup>
2825
<ItemGroup>
29-
<ClInclude Include="EndBrace.h">
26+
<ClInclude Include="Log.h">
3027
<Filter>Fichiers d%27en-tête</Filter>
3128
</ClInclude>
3229
</ItemGroup>

HelloWorld/Log.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#include <iostream>
2+
#include "Log.h"
3+
4+
void InitLog()
5+
{
6+
Log("Initialized Log");
7+
}
28

39
void Log(const char* message)
410
{

HelloWorld/Log.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
void Log(const char* message);

HelloWorld/Main.cpp

Lines changed: 0 additions & 9 deletions
This file was deleted.

HelloWorld/Math.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
const char* Log(const char* message)
1+
#include <iostream>
2+
#include "Log.h"
3+
4+
static int Multiply(int a, int b)
25
{
3-
return message;
6+
Log("Multiply");
7+
return a * b;
48
}
59

6-
int Multiply(int a, int b)
10+
int main()
711
{
8-
Log("Multiply")
9-
return a * b;
12+
std::cout << Multiply(5, 8) << std::endl;
13+
std::cin.get();
1014
}

0 commit comments

Comments
 (0)