Roll back cb198413 re MSVC __cplusplus macro

Commit cb19841358 "Work around MSVC's
__cplusplus regarding C++11" did not fix compiler errors with older MSVC
versions as hoped.
This commit is contained in:
Nigel Tao committed 2020-06-17 21:18:36 +10:00
1 parent 025f9c208e
commit 824b87bb86
4 files changed
+58 -68

No files matched your search

+50 -55
View File
@@ -36,14 +36,9 @@
#include <string.h>
#ifdef __cplusplus
// MSVC before Visual Studio 2017 mis-reported the __cplusplus level:
// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
// We just assume that ifdef __cplusplus, MSVC implies C++11 or later. Note
// that MSVC doesn't support "#warning" and Clang also defines __GNUC__.
#if (__cplusplus >= 201103L) || defined(_MSC_VER)
#define WUFFS_HAS_CPP11
#if __cplusplus >= 201103L
#include <memory>
#elif defined(__GNUC__)
#else
#warning "Wuffs' C++ code requires -std=c++11 or later"
#endif
@@ -4177,7 +4172,7 @@ struct wuffs_base__hasher_u32__struct {
} private_impl;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_base__hasher_u32, decltype(&free)>;
#endif
@@ -4328,7 +4323,7 @@ struct wuffs_base__image_decoder__struct {
} private_impl;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_base__image_decoder, decltype(&free)>;
#endif
@@ -4469,7 +4464,7 @@ struct wuffs_base__io_transformer__struct {
} private_impl;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_base__io_transformer, decltype(&free)>;
#endif
@@ -4547,7 +4542,7 @@ struct wuffs_base__token_decoder__struct {
} private_impl;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_base__token_decoder, decltype(&free)>;
#endif
@@ -4679,7 +4674,7 @@ struct wuffs_adler32__hasher__struct {
} private_impl;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_adler32__hasher, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -4694,9 +4689,9 @@ struct wuffs_adler32__hasher__struct {
return wuffs_base__hasher_u32::unique_ptr(
wuffs_adler32__hasher__alloc_as__wuffs_base__hasher_u32(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -4722,7 +4717,7 @@ struct wuffs_adler32__hasher__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -4954,7 +4949,7 @@ struct wuffs_bmp__decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_bmp__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -4969,9 +4964,9 @@ struct wuffs_bmp__decoder__struct {
return wuffs_base__image_decoder::unique_ptr(
wuffs_bmp__decoder__alloc_as__wuffs_base__image_decoder(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -4997,7 +4992,7 @@ struct wuffs_bmp__decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -5194,7 +5189,7 @@ struct wuffs_crc32__ieee_hasher__struct {
} private_impl;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_crc32__ieee_hasher, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -5209,9 +5204,9 @@ struct wuffs_crc32__ieee_hasher__struct {
return wuffs_base__hasher_u32::unique_ptr(
wuffs_crc32__ieee_hasher__alloc_as__wuffs_base__hasher_u32(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -5237,7 +5232,7 @@ struct wuffs_crc32__ieee_hasher__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -5448,7 +5443,7 @@ struct wuffs_deflate__decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_deflate__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -5463,9 +5458,9 @@ struct wuffs_deflate__decoder__struct {
return wuffs_base__io_transformer::unique_ptr(
wuffs_deflate__decoder__alloc_as__wuffs_base__io_transformer(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -5491,7 +5486,7 @@ struct wuffs_deflate__decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -5676,7 +5671,7 @@ struct wuffs_lzw__decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_lzw__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -5691,9 +5686,9 @@ struct wuffs_lzw__decoder__struct {
return wuffs_base__io_transformer::unique_ptr(
wuffs_lzw__decoder__alloc_as__wuffs_base__io_transformer(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -5719,7 +5714,7 @@ struct wuffs_lzw__decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -6120,7 +6115,7 @@ struct wuffs_gif__config_decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_gif__config_decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -6135,9 +6130,9 @@ struct wuffs_gif__config_decoder__struct {
return wuffs_base__image_decoder::unique_ptr(
wuffs_gif__config_decoder__alloc_as__wuffs_base__image_decoder(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -6163,7 +6158,7 @@ struct wuffs_gif__config_decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -6383,7 +6378,7 @@ struct wuffs_gif__decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_gif__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -6398,9 +6393,9 @@ struct wuffs_gif__decoder__struct {
return wuffs_base__image_decoder::unique_ptr(
wuffs_gif__decoder__alloc_as__wuffs_base__image_decoder(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -6426,7 +6421,7 @@ struct wuffs_gif__decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -6656,7 +6651,7 @@ struct wuffs_gzip__decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_gzip__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -6671,9 +6666,9 @@ struct wuffs_gzip__decoder__struct {
return wuffs_base__io_transformer::unique_ptr(
wuffs_gzip__decoder__alloc_as__wuffs_base__io_transformer(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -6699,7 +6694,7 @@ struct wuffs_gzip__decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -6923,7 +6918,7 @@ struct wuffs_json__decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_json__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -6938,9 +6933,9 @@ struct wuffs_json__decoder__struct {
return wuffs_base__token_decoder::unique_ptr(
wuffs_json__decoder__alloc_as__wuffs_base__token_decoder(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -6966,7 +6961,7 @@ struct wuffs_json__decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -7190,7 +7185,7 @@ struct wuffs_wbmp__decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_wbmp__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -7205,9 +7200,9 @@ struct wuffs_wbmp__decoder__struct {
return wuffs_base__image_decoder::unique_ptr(
wuffs_wbmp__decoder__alloc_as__wuffs_base__image_decoder(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -7233,7 +7228,7 @@ struct wuffs_wbmp__decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -7478,7 +7473,7 @@ struct wuffs_zlib__decoder__struct {
} private_data;
#ifdef __cplusplus
#if defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L)
using unique_ptr = std::unique_ptr<wuffs_zlib__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -7493,9 +7488,9 @@ struct wuffs_zlib__decoder__struct {
return wuffs_base__io_transformer::unique_ptr(
wuffs_zlib__decoder__alloc_as__wuffs_base__io_transformer(), &free);
}
#endif // defined(WUFFS_HAS_CPP11)
#endif // (__cplusplus >= 201103L)
#if defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
// Disallow constructing or copying an object via standard C++ mechanisms,
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
// size and field layout is not part of the public, stable, memory-safe API.
@@ -7521,7 +7516,7 @@ struct wuffs_zlib__decoder__struct {
// different, so that passing the latter will be rejected by the initialize
// function, we add an arbitrary amount of dead weight.
uint8_t dead_weight[123000000]; // 123 MB.
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(