Skip to content

Commit 01aa23a

Browse files
authored
Apply updates for Visual Studio 2022 17.11 (#46)
- Use fmt_ptr instead of static_cast<void*> when using TRACE - Rename C++ only headers to .hpp - Remove not needed warning suppressions - Update spelling.dic - Compile in (draft) C++23 mode - Replace module header "std.h" with named module std;
1 parent 79b5621 commit 01aa23a

38 files changed

+283
-245
lines changed

.gitattributes

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Set default behavior to automatically normalize line endings.
55
* text=auto
66

7+
# Explicit use CRLF for spell checker exclusion file.
8+
*.dic text eol=crlf
9+
710
# Explicit define text files types.
811
*.cpp text diff=cpp
912
*.ixx text diff=cpp
@@ -21,4 +24,4 @@
2124
.gitattributes text export-ignore
2225
.gitignore text export-ignore
2326
.gitmodules text export-ignore
24-
.azure-pipelines.yml text export-ignore
27+
.azure-pipelines.yml text export-ignore

Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
<!-- Use all cores to speed up the compilation (MS recommended best practice). -->
3030
<MultiProcessorCompilation>true</MultiProcessorCompilation>
3131

32-
<!-- Explicit define that all projects are compiled according the C++20 standard -->
33-
<LanguageStandard>stdcpp20</LanguageStandard>
32+
<!-- Explicit define that all projects are compiled according the draft C++23 standard -->
33+
<LanguageStandard>stdcpplatest</LanguageStandard>
3434
<UseStandardPreprocessor>true</UseStandardPreprocessor>
3535

3636
<!-- To ensure high quality C++ code use warning level 4 and treat warnings as errors to ensure warnings are fixed promptly. -->

netpbm-wic-codec.sln.DotSettings

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<s:Boolean x:Key="/Default/UserDictionary/Words/=defacto/@EntryIndexedValue">True</s:Boolean>
99
<s:Boolean x:Key="/Default/UserDictionary/Words/=Derks/@EntryIndexedValue">True</s:Boolean>
1010
<s:Boolean x:Key="/Default/UserDictionary/Words/=endian/@EntryIndexedValue">True</s:Boolean>
11+
<s:Boolean x:Key="/Default/UserDictionary/Words/=fmtlib/@EntryIndexedValue">True</s:Boolean>
1112
<s:Boolean x:Key="/Default/UserDictionary/Words/=graymap/@EntryIndexedValue">True</s:Boolean>
1213
<s:Boolean x:Key="/Default/UserDictionary/Words/=hkey/@EntryIndexedValue">True</s:Boolean>
1314
<s:Boolean x:Key="/Default/UserDictionary/Words/=hresult/@EntryIndexedValue">True</s:Boolean>

spelling.dic

+14
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11

22
hkey
3+
misc
4+
bugprone
5+
Intelli
6+
cppcoreguidelines
7+
Multiframe
8+
inproc
9+
fccd
10+
pgmfile
11+
graymap
12+
ppmfile
13+
pixmap
14+
derks
15+
bcfd
16+
Anymap

src/buffered_stream_reader.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Copyright (c) Victor Derks.
22
// SPDX-License-Identifier: MIT
33

4+
module;
5+
6+
#include "intellisense.hpp"
7+
48
module buffered_stream_reader;
59

6-
import <std.h>;
710
import <win.h>;
8-
import winrt;
911

1012
import errors;
1113
import util;

src/buffered_stream_reader.ixx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
// Copyright (c) Victor Derks.
22
// SPDX-License-Identifier: MIT
33

4+
module;
5+
6+
#include "intellisense.hpp"
7+
48
export module buffered_stream_reader;
59

610
import <win.h>;
7-
import <std.h>;
11+
import std;
812
import winrt;
913

1014
export class buffered_stream_reader final
@@ -15,7 +19,7 @@ public:
1519
HRESULT ReadChar(char* c);
1620
HRESULT SkipLine();
1721
HRESULT ReadString(char* str, ULONG maxCount);
18-
[[nodiscard]] uint32_t read_int_slow();
22+
[[nodiscard]] std::uint32_t read_int_slow();
1923
bool try_read_bytes(void* buffer, size_t size);
2024
void read_bytes(void* buffer, size_t size);
2125

src/dll_main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Victor Derks.
22
// SPDX-License-Identifier: MIT
33

4-
#include "macros.h"
4+
#include "macros.hpp"
55
#include "version.h"
66

7-
import <std.h>;
7+
import std;
88
import <win.h>;
99
import winrt;
1010

@@ -131,7 +131,7 @@ void register_decoder()
131131
// ReSharper disable CppInconsistentNaming
132132
// ReSharper disable CppParameterNamesMismatch
133133

134-
BOOL APIENTRY DllMain(const HMODULE module, const DWORD reason_for_call, void* /*reserved*/) noexcept
134+
BOOL __stdcall DllMain(const HMODULE module, const DWORD reason_for_call, void* /*reserved*/) noexcept
135135
{
136136
switch (reason_for_call)
137137
{

src/errors.ixx

+21-21
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,42 @@
33

44
module;
55

6-
#include "macros.h"
6+
#include "intellisense.hpp"
77

88
export module errors;
99

1010
import <win.h>;
1111

1212
export {
1313

14-
inline constexpr HRESULT error_ok{S_OK};
15-
inline constexpr HRESULT error_fail{E_FAIL};
16-
inline constexpr HRESULT error_pointer{E_POINTER};
17-
inline constexpr HRESULT error_no_aggregation{CLASS_E_NOAGGREGATION};
18-
inline constexpr HRESULT error_class_not_available{CLASS_E_CLASSNOTAVAILABLE};
19-
inline constexpr HRESULT error_invalid_argument{E_INVALIDARG};
14+
constexpr HRESULT error_ok{S_OK};
15+
constexpr HRESULT error_fail{E_FAIL};
16+
constexpr HRESULT error_pointer{E_POINTER};
17+
constexpr HRESULT error_no_aggregation{CLASS_E_NOAGGREGATION};
18+
constexpr HRESULT error_class_not_available{CLASS_E_CLASSNOTAVAILABLE};
19+
constexpr HRESULT error_invalid_argument{E_INVALIDARG};
2020

2121
namespace self_registration {
2222

23-
inline constexpr HRESULT error_class{SELFREG_E_CLASS};
23+
constexpr HRESULT error_class{SELFREG_E_CLASS};
2424

2525
}
2626

2727
namespace wincodec {
2828

29-
inline constexpr HRESULT error_palette_unavailable{WINCODEC_ERR_PALETTEUNAVAILABLE};
30-
inline constexpr HRESULT error_unsupported_operation{WINCODEC_ERR_UNSUPPORTEDOPERATION};
31-
inline constexpr HRESULT error_codec_no_thumbnail{WINCODEC_ERR_CODECNOTHUMBNAIL};
32-
inline constexpr HRESULT error_frame_missing{WINCODEC_ERR_FRAMEMISSING};
33-
inline constexpr HRESULT error_not_initialized{WINCODEC_ERR_NOTINITIALIZED};
34-
inline constexpr HRESULT error_wrong_state{WINCODEC_ERR_WRONGSTATE};
35-
inline constexpr HRESULT error_unsupported_pixel_format{WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT};
36-
inline constexpr HRESULT error_codec_too_many_scan_lines{WINCODEC_ERR_CODECTOOMANYSCANLINES};
37-
inline constexpr HRESULT error_component_not_found{WINCODEC_ERR_COMPONENTNOTFOUND};
38-
inline constexpr HRESULT error_bad_header{WINCODEC_ERR_BADHEADER};
39-
inline constexpr HRESULT error_bad_image{WINCODEC_ERR_BADIMAGE};
40-
inline constexpr HRESULT error_stream_not_available{WINCODEC_ERR_STREAMNOTAVAILABLE};
41-
inline constexpr HRESULT error_stream_read{WINCODEC_ERR_STREAMREAD};
29+
constexpr HRESULT error_palette_unavailable{WINCODEC_ERR_PALETTEUNAVAILABLE};
30+
constexpr HRESULT error_unsupported_operation{WINCODEC_ERR_UNSUPPORTEDOPERATION};
31+
constexpr HRESULT error_codec_no_thumbnail{WINCODEC_ERR_CODECNOTHUMBNAIL};
32+
constexpr HRESULT error_frame_missing{WINCODEC_ERR_FRAMEMISSING};
33+
constexpr HRESULT error_not_initialized{WINCODEC_ERR_NOTINITIALIZED};
34+
constexpr HRESULT error_wrong_state{WINCODEC_ERR_WRONGSTATE};
35+
constexpr HRESULT error_unsupported_pixel_format{WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT};
36+
constexpr HRESULT error_codec_too_many_scan_lines{WINCODEC_ERR_CODECTOOMANYSCANLINES};
37+
constexpr HRESULT error_component_not_found{WINCODEC_ERR_COMPONENTNOTFOUND};
38+
constexpr HRESULT error_bad_header{WINCODEC_ERR_BADHEADER};
39+
constexpr HRESULT error_bad_image{WINCODEC_ERR_BADIMAGE};
40+
constexpr HRESULT error_stream_not_available{WINCODEC_ERR_STREAMNOTAVAILABLE};
41+
constexpr HRESULT error_stream_read{WINCODEC_ERR_STREAMREAD};
4242

4343
} // namespace wincodec
4444

src/guids.ixx

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import <win.h>;
88
export namespace id {
99

1010
// {06891bbe-cc02-4bb2-9cf0-303fc4e668c3}
11-
inline constexpr GUID netpbm_decoder{0x6891bbe, 0xcc02, 0x4bb2, {0x9c, 0xf0, 0x30, 0x3f, 0xc4, 0xe6, 0x68, 0xc3}};
11+
constexpr GUID netpbm_decoder{0x6891bbe, 0xcc02, 0x4bb2, {0x9c, 0xf0, 0x30, 0x3f, 0xc4, 0xe6, 0x68, 0xc3}};
1212

1313
// {70ab66f5-cd48-43a1-aa29-10131b7f4ff1}
14-
inline constexpr GUID container_format_netpbm{0x70ab66f5, 0xcd48, 0x43a1, {0xaa, 0x29, 0x10, 0x13, 0x1b, 0x7f, 0x4f, 0xf1}};
14+
constexpr GUID container_format_netpbm{0x70ab66f5, 0xcd48, 0x43a1, {0xaa, 0x29, 0x10, 0x13, 0x1b, 0x7f, 0x4f, 0xf1}};
1515

1616
// {87a8e9f4-8aac-4667-bcfd-56535c80a269}
17-
inline constexpr GUID vendor_victor_derks{0x87a8e9f4, 0x8aac, 0x4667, {0xbc, 0xfd, 0x56, 0x53, 0x5c, 0x80, 0xa2, 0x69}};
17+
constexpr GUID vendor_victor_derks{0x87a8e9f4, 0x8aac, 0x4667, {0xbc, 0xfd, 0x56, 0x53, 0x5c, 0x80, 0xa2, 0x69}};
1818

1919
}

src/intellisense.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) Victor Derks.
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
// Include explicit headers as workaround that IntelliSense in VS 2022 17.12 fails to parse #import <win.h>
7+
#ifdef __INTELLISENSE__
8+
#define _AMD64_
9+
#include <combaseapi.h>
10+
#include <libloaderapi.h>
11+
#include <sal.h>
12+
#include <wincodec.h>
13+
#include <winreg.h>
14+
#endif

src/macros.h

-54
This file was deleted.

src/macros.hpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) Victor Derks.
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
#include <cassert>
7+
8+
#include "intellisense.hpp"
9+
10+
#define SUPPRESS_WARNING_NEXT_LINE(x) \
11+
__pragma(warning(suppress \
12+
: x)) // NOLINT(misc-macro-parentheses, bugprone-macro-parentheses, cppcoreguidelines-macro-usage)
13+
14+
#ifdef NDEBUG
15+
16+
#define ASSERT(expression) static_cast<void>(0)
17+
#define VERIFY(expression) static_cast<void>(expression)
18+
19+
#else
20+
21+
#define ASSERT(expression) \
22+
__pragma(warning(push)) __pragma(warning(disable : 26493)) assert(expression) __pragma(warning(pop))
23+
#define VERIFY(expression) assert(expression)
24+
25+
#endif
26+
27+
// The TRACE macro can be used in debug build to watch the behaviour of the implementation
28+
// when used by 3rd party applications.
29+
#ifdef NDEBUG
30+
#define TRACE __noop
31+
#else
32+
// Use std::format directly to get compile time checking of the string arguments.
33+
#define TRACE(fmt, ...) OutputDebugStringA(std::format(fmt __VA_OPT__(,) __VA_ARGS__).c_str())
34+
#endif

src/netpbm-wic-codec.vcxproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@
192192
</Link>
193193
</ItemDefinitionGroup>
194194
<ItemGroup>
195-
<ClInclude Include="macros.h" />
195+
<ClInclude Include="intellisense.hpp" />
196+
<ClInclude Include="macros.hpp" />
196197
<ClInclude Include="version.h" />
197198
</ItemGroup>
198199
<ItemGroup>

src/netpbm-wic-codec.vcxproj.filters

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
<ClInclude Include="version.h">
1919
<Filter>Header Files</Filter>
2020
</ClInclude>
21-
<ClInclude Include="macros.h">
21+
<ClInclude Include="macros.hpp">
22+
<Filter>Header Files</Filter>
23+
</ClInclude>
24+
<ClInclude Include="intellisense.hpp">
2225
<Filter>Header Files</Filter>
2326
</ClInclude>
2427
</ItemGroup>

0 commit comments

Comments
 (0)