Skip to content

Commit d69eeb9

Browse files
committed
Code improvement
1. Remove `_CRT_SECURE_NO_WARNINGS` supression 2. Treat linker warning as error. 3. Move thirdparty code under `ExternalIncludePath` 4. Enable whole program optimization for debug build 5. Use debug libraries in debug mode
1 parent 4a51f7a commit d69eeb9

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

NppJSONViewer/NppJsonViewer/NPPJSONViewer.vcxproj

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,37 @@
3737
<ConfigurationType>DynamicLibrary</ConfigurationType>
3838
<CharacterSet>Unicode</CharacterSet>
3939
<PlatformToolset>v143</PlatformToolset>
40+
<UseDebugLibraries>true</UseDebugLibraries>
4041
</PropertyGroup>
4142
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
4243
<ConfigurationType>DynamicLibrary</ConfigurationType>
4344
<CharacterSet>Unicode</CharacterSet>
4445
<PlatformToolset>v143</PlatformToolset>
46+
<WholeProgramOptimization>true</WholeProgramOptimization>
4547
</PropertyGroup>
4648
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
4749
<ConfigurationType>DynamicLibrary</ConfigurationType>
4850
<CharacterSet>Unicode</CharacterSet>
4951
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
5053
</PropertyGroup>
5154
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
5255
<ConfigurationType>DynamicLibrary</ConfigurationType>
5356
<CharacterSet>Unicode</CharacterSet>
5457
<PlatformToolset>v143</PlatformToolset>
58+
<WholeProgramOptimization>true</WholeProgramOptimization>
5559
</PropertyGroup>
5660
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
5761
<ConfigurationType>DynamicLibrary</ConfigurationType>
5862
<CharacterSet>Unicode</CharacterSet>
5963
<PlatformToolset>v143</PlatformToolset>
64+
<UseDebugLibraries>true</UseDebugLibraries>
6065
</PropertyGroup>
6166
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
6267
<ConfigurationType>DynamicLibrary</ConfigurationType>
6368
<CharacterSet>Unicode</CharacterSet>
6469
<PlatformToolset>v143</PlatformToolset>
70+
<UseDebugLibraries>true</UseDebugLibraries>
6571
</PropertyGroup>
6672
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
6773
<ImportGroup Label="ExtensionSettings">
@@ -107,27 +113,33 @@
107113
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
108114
</PropertyGroup>
109115
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
110-
<IncludePath>$(SolutionDir)UtilityLib;$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(IncludePath)</IncludePath>
116+
<IncludePath>$(SolutionDir)UtilityLib;$(IncludePath)</IncludePath>
117+
<ExternalIncludePath>$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(ExternalIncludePath)</ExternalIncludePath>
111118
</PropertyGroup>
112119
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
113-
<IncludePath>$(SolutionDir)UtilityLib;$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(IncludePath)</IncludePath>
120+
<IncludePath>$(SolutionDir)UtilityLib;$(IncludePath)</IncludePath>
121+
<ExternalIncludePath>$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(ExternalIncludePath)</ExternalIncludePath>
114122
</PropertyGroup>
115123
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
116-
<IncludePath>$(SolutionDir)UtilityLib;$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(IncludePath)</IncludePath>
124+
<IncludePath>$(SolutionDir)UtilityLib;$(IncludePath)</IncludePath>
125+
<ExternalIncludePath>$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(ExternalIncludePath)</ExternalIncludePath>
117126
</PropertyGroup>
118127
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
119-
<IncludePath>$(SolutionDir)UtilityLib;$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(IncludePath)</IncludePath>
128+
<IncludePath>$(SolutionDir)UtilityLib;$(IncludePath)</IncludePath>
129+
<ExternalIncludePath>$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(ExternalIncludePath)</ExternalIncludePath>
120130
</PropertyGroup>
121131
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
122-
<IncludePath>$(SolutionDir)UtilityLib;$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(IncludePath)</IncludePath>
132+
<IncludePath>$(SolutionDir)UtilityLib;$(IncludePath)</IncludePath>
133+
<ExternalIncludePath>$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(ExternalIncludePath)</ExternalIncludePath>
123134
</PropertyGroup>
124135
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
125-
<IncludePath>$(SolutionDir)UtilityLib;$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(IncludePath)</IncludePath>
136+
<IncludePath>$(SolutionDir)UtilityLib;$(IncludePath)</IncludePath>
137+
<ExternalIncludePath>$(SolutionDir)external\npp;$(SolutionDir)external\rapidjson\include;$(ExternalIncludePath)</ExternalIncludePath>
126138
</PropertyGroup>
127139
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
128140
<ClCompile>
129141
<Optimization>Disabled</Optimization>
130-
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
142+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
131143
<MinimalRebuild>false</MinimalRebuild>
132144
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
133145
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@@ -144,12 +156,13 @@
144156
<GenerateDebugInformation>true</GenerateDebugInformation>
145157
<SubSystem>Windows</SubSystem>
146158
<TargetMachine>MachineX64</TargetMachine>
159+
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
147160
</Link>
148161
</ItemDefinitionGroup>
149162
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
150163
<ClCompile>
151164
<Optimization>Disabled</Optimization>
152-
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
165+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
153166
<MinimalRebuild>false</MinimalRebuild>
154167
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
155168
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@@ -165,11 +178,12 @@
165178
<AdditionalDependencies>shlwapi.lib;comctl32.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
166179
<GenerateDebugInformation>true</GenerateDebugInformation>
167180
<SubSystem>Windows</SubSystem>
181+
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
168182
</Link>
169183
</ItemDefinitionGroup>
170184
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
171185
<ClCompile>
172-
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
186+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
173187
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
174188
<WarningLevel>Level4</WarningLevel>
175189
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@@ -186,11 +200,12 @@
186200
<OptimizeReferences>true</OptimizeReferences>
187201
<EnableCOMDATFolding>true</EnableCOMDATFolding>
188202
<TargetMachine>MachineX64</TargetMachine>
203+
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
189204
</Link>
190205
</ItemDefinitionGroup>
191206
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
192207
<ClCompile>
193-
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
208+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
194209
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
195210
<WarningLevel>Level4</WarningLevel>
196211
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@@ -206,11 +221,12 @@
206221
<SubSystem>Windows</SubSystem>
207222
<OptimizeReferences>true</OptimizeReferences>
208223
<EnableCOMDATFolding>true</EnableCOMDATFolding>
224+
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
209225
</Link>
210226
</ItemDefinitionGroup>
211227
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
212228
<ClCompile>
213-
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
229+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
214230
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
215231
<WarningLevel>Level4</WarningLevel>
216232
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@@ -227,12 +243,13 @@
227243
<OptimizeReferences>true</OptimizeReferences>
228244
<EnableCOMDATFolding>true</EnableCOMDATFolding>
229245
<TargetMachine>MachineX86</TargetMachine>
246+
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
230247
</Link>
231248
</ItemDefinitionGroup>
232249
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
233250
<ClCompile>
234251
<Optimization>Disabled</Optimization>
235-
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
252+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NPPJSONVIEWER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
236253
<MinimalRebuild>false</MinimalRebuild>
237254
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
238255
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@@ -249,6 +266,7 @@
249266
<GenerateDebugInformation>true</GenerateDebugInformation>
250267
<SubSystem>Windows</SubSystem>
251268
<TargetMachine>MachineX86</TargetMachine>
269+
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
252270
</Link>
253271
</ItemDefinitionGroup>
254272
<ItemGroup>

NppJSONViewer/external/npp/StaticDialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ void StaticDialog::create(int dialogID, bool isRTL)
8484
if (!_hSelf)
8585
{
8686
DWORD err = ::GetLastError();
87-
char errMsg[256];
88-
sprintf(errMsg, "CreateDialogParam() return NULL.\rGetLastError() == %lu", err);
87+
char errMsg[256] {};
88+
sprintf_s(errMsg, "CreateDialogParam() return NULL.\rGetLastError() == %lu", err);
8989
::MessageBoxA(NULL, errMsg, "In StaticDialog::create()", MB_OK);
9090
return;
9191
}

0 commit comments

Comments
 (0)