Work around MSVC's __cplusplus regarding C++11

This commit is contained in:
Nigel Tao committed 2020-06-17 06:39:45 +10:00
1 parent 635b502649
commit cb19841358
4 files changed
+68 -58

No files matched your search

+55 -50
View File
@@ -36,9 +36,14 @@
#include <string.h>
#ifdef __cplusplus
#if __cplusplus >= 201103L
// 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
#include <memory>
#else
#elif defined(__GNUC__)
#warning "Wuffs' C++ code requires -std=c++11 or later"
#endif
@@ -4172,7 +4177,7 @@ struct wuffs_base__hasher_u32__struct {
} private_impl;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_base__hasher_u32, decltype(&free)>;
#endif
@@ -4323,7 +4328,7 @@ struct wuffs_base__image_decoder__struct {
} private_impl;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_base__image_decoder, decltype(&free)>;
#endif
@@ -4464,7 +4469,7 @@ struct wuffs_base__io_transformer__struct {
} private_impl;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_base__io_transformer, decltype(&free)>;
#endif
@@ -4542,7 +4547,7 @@ struct wuffs_base__token_decoder__struct {
} private_impl;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_base__token_decoder, decltype(&free)>;
#endif
@@ -4674,7 +4679,7 @@ struct wuffs_adler32__hasher__struct {
} private_impl;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_adler32__hasher, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -4689,9 +4694,9 @@ struct wuffs_adler32__hasher__struct {
return wuffs_base__hasher_u32::unique_ptr(
wuffs_adler32__hasher__alloc_as__wuffs_base__hasher_u32(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -4717,7 +4722,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -4949,7 +4954,7 @@ struct wuffs_bmp__decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_bmp__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -4964,9 +4969,9 @@ struct wuffs_bmp__decoder__struct {
return wuffs_base__image_decoder::unique_ptr(
wuffs_bmp__decoder__alloc_as__wuffs_base__image_decoder(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -4992,7 +4997,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -5189,7 +5194,7 @@ struct wuffs_crc32__ieee_hasher__struct {
} private_impl;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_crc32__ieee_hasher, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -5204,9 +5209,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 // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -5232,7 +5237,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -5443,7 +5448,7 @@ struct wuffs_deflate__decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_deflate__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -5458,9 +5463,9 @@ struct wuffs_deflate__decoder__struct {
return wuffs_base__io_transformer::unique_ptr(
wuffs_deflate__decoder__alloc_as__wuffs_base__io_transformer(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -5486,7 +5491,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -5671,7 +5676,7 @@ struct wuffs_lzw__decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_lzw__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -5686,9 +5691,9 @@ struct wuffs_lzw__decoder__struct {
return wuffs_base__io_transformer::unique_ptr(
wuffs_lzw__decoder__alloc_as__wuffs_base__io_transformer(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -5714,7 +5719,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -6115,7 +6120,7 @@ struct wuffs_gif__config_decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_gif__config_decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -6130,9 +6135,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 // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -6158,7 +6163,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -6378,7 +6383,7 @@ struct wuffs_gif__decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_gif__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -6393,9 +6398,9 @@ struct wuffs_gif__decoder__struct {
return wuffs_base__image_decoder::unique_ptr(
wuffs_gif__decoder__alloc_as__wuffs_base__image_decoder(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -6421,7 +6426,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -6651,7 +6656,7 @@ struct wuffs_gzip__decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_gzip__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -6666,9 +6671,9 @@ struct wuffs_gzip__decoder__struct {
return wuffs_base__io_transformer::unique_ptr(
wuffs_gzip__decoder__alloc_as__wuffs_base__io_transformer(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -6694,7 +6699,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -6918,7 +6923,7 @@ struct wuffs_json__decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_json__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -6933,9 +6938,9 @@ struct wuffs_json__decoder__struct {
return wuffs_base__token_decoder::unique_ptr(
wuffs_json__decoder__alloc_as__wuffs_base__token_decoder(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -6961,7 +6966,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -7185,7 +7190,7 @@ struct wuffs_wbmp__decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_wbmp__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -7200,9 +7205,9 @@ struct wuffs_wbmp__decoder__struct {
return wuffs_base__image_decoder::unique_ptr(
wuffs_wbmp__decoder__alloc_as__wuffs_base__image_decoder(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -7228,7 +7233,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(
@@ -7473,7 +7478,7 @@ struct wuffs_zlib__decoder__struct {
} private_data;
#ifdef __cplusplus
#if __cplusplus >= 201103L
#if defined(WUFFS_HAS_CPP11)
using unique_ptr = std::unique_ptr<wuffs_zlib__decoder, decltype(&free)>;
// On failure, the alloc_etc functions return nullptr. They don't throw.
@@ -7488,9 +7493,9 @@ struct wuffs_zlib__decoder__struct {
return wuffs_base__io_transformer::unique_ptr(
wuffs_zlib__decoder__alloc_as__wuffs_base__io_transformer(), &free);
}
#endif // __cplusplus >= 201103L
#endif // defined(WUFFS_HAS_CPP11)
#if (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#if defined(WUFFS_HAS_CPP11) && !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.
@@ -7516,7 +7521,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 // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
#endif // defined(WUFFS_HAS_CPP11) && !defined(WUFFS_IMPLEMENTATION)
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
initialize(