Skip to content

Commit

Permalink
?cxx/Macros.hxx: +SUSUWU_DEFAULT, +SUSUWU_FINAL,
Browse files Browse the repository at this point in the history
	+`SUSUWU_DELETE`, +`SUSUWU_OVERRIDE`: common C++11 attributes, which turn into no-ops if `!defined(SUSUWU_CXX11)` -- progress to issue #20 (C++98 support.)
	+`SUSUWU_C99`, `SUSUWU_CXX98`: Usage: `#ifdef SUSUWU_C99`, `#ifdef SUSUWU_CXX98`.
	+`SUSUWU_EXTERN`, +`SUSUWU_STATIC`, +`SUSUWU_INLINE`: Wrap `extern`, `static`, `inline` for possible future instrumentation/diagnostic use.
	+`SUSUWU_NULLPTR`: if `defined(SUSUWU_CXX11)`; `nullptr`, else; `NULL`.
	?`SUSUWU_SH_FUNC`: if `!defined(SUSUWU_C99) && !defined(SUSUWU_CXX11)`, `__func__` deactivates.

?`cxx/ClassCns.*xx`, `cxx/ClassPortableExecutable.hxx`, `cxx/ClassResultList.hxx``: `:%s/override/SUSUWU_OVERRIDE/`.
?`cxx/ClassCns.hxx`, ?`cxx/ClassObject.hxx`: `:%s/= default/= SUSUWU_DEFAULT/`.
?`cxx/ClassSys.*xx`: `:%s/nullptr/SUSUWU_NULLPTR/`.

?`cxx/Macros.cxx:
	+`MacrosCxx11InheritanceTest`: tests `SUSUWU_DEFAULT`, tests `SUSUWU_DELETE`.
	+`MacrosCxx11InheritanceTestSubclass`: tests `SUSUWU_OVERRIDE`.
	+`MacrosCxx11InheritanceTestSubclass2`: tests `SUSUWU_FINAL`.
	If those compile, the test passes.

?`posts/VirusAnalysis.md`: Include all this.

?`README.md`:
  -`Targets:`, +`Minimum requirements (build targets which this supports):`: list what more there is to do for #3, #20

Is followup to: commit bf1fec0 (... ?`cxx/Macros.hxx`: +`SUSUWU_POSIX` +`SUSUWU_WIN32` +`SUSUWU_HAS_FEATURE` +`SUSUWU_HAS_ATTRIBUTE`), e6ef262 (+`SUSUWU_C11`. +`SUSUWU_CONSTEXPR` ... `%s/noexcept/SUSUWU_NOEXCEPT/`), 08ed827 (?`cxx/macros.hxx`: +`SUSUWU_CXX11`, ...)
  • Loading branch information
SwuduSusuwu committed Nov 18, 2024
1 parent bf1fec0 commit 4920b4a
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 64 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ Dual licenses: choose [_Creative Commons_](https://creativecommons.org/share-you
# Purposes
[`./posts/`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/posts/) stages posts (school classes) for https://SwuduSusuwu.SubStack.com/ about artificial neural tissue, antivirus, assistants, plus autonomous tools.

[`./c/`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/c/) _C_ implementations of posts (TODO, has [issue](https://github.com/SwuduSusuwu/SubStack/issues/3) which you can contribute to, or can request that more resources go to this task), + vendored code (for now just _RFC6234_, for `sha2`).
[`./c/`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/c/) _C_ implementations of posts (TODO, [issue #3](https://github.com/SwuduSusuwu/SubStack/issues/3) which you can contribute to, or can request that more resources go to this task), + vendored code (for now just _RFC6234_, for `sha2`).

[`./cxx/`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/cxx/) _C++_ implementations of posts (for now is just neural system pure virtual template ([`./cxx/ClassCns.hxx`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/cxx/ClassCns.hxx)) + antivirus([`./cxx/VirusAnalysis.cxx`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/cxx/VirusAnalysis.cxx)) + assistant([`./cxx/AssistantCns.cxx`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/cxx/AssistantCns.cxx)), with lots of [issues](https://github.com/SwuduSusuwu/SubStack/issues) which you can contribute to, or can request that more resources go to).

# How to use this
Targets: Windows/Linux/Android/OSX/iOS; minimum [_C++11_](https://gcc.gnu.org/projects/cxx-status.html#cxx11) (all `CXX` with `201102 <= __cplusplus`,) due to use of `auto`, `class {bool defaultMemberInit = true};`, `decltype`, `for(value: list) {}`, `nullptr`, `__func__`).
Minimum requirements (build targets which this supports):
- Operating systems: _Windows_, _Linux_ (such as _Android_ or _Ubuntu_), _Unix_ (such as _BSD_, _Solaris_ or _Mach_/_OSX_), or _iOS_.
- Languages: Minimum [_C++11_](https://gcc.gnu.org/projects/cxx-status.html#cxx11) (all `CXX` with `201102 <= __cplusplus`,) due to use of `auto`, `class {bool defaultMemberInit = true};`, `decltype`, `for(value: list) {}`).
- Other than those 4, most non-[_C++98_](https://gcc.gnu.org/projects/cxx-status.html#cxx98) features were replaced with `cxx/Macros.hxx` macros (which turn into no-ops if the compile doesn't support those), such as: [`constexpr`, `default`, `final`, `__func__`, `override`, `noexcept`, `nullptr`, `static_asset`](https://gcc.gnu.org/projects/cxx-status.html#cxx11), [`[[no_unique_address]]`](https://gcc.gnu.org/projects/cxx-status.html#cxx20).
- If you must have _C99_ support; ask for this (in [issue #3](https://github.com/SwuduSusuwu/SubStack/issues/3)), or [contribute](#Contributor-conventionsrules).
- If you must have _C++98_ support; ask for this (in [issue #20](https://github.com/SwuduSusuwu/SubStack/issues/20)), or [contribute](#Contributor-conventionsrules).

Usage: [`./build.sh [OPTIONS]`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/build.sh) produces objects (`./obj/*.o`, for distribution into other tools,) plus [_Executable and Linkable Format_](https://wikipedia.org/wiki/Executable_and_Linkable_Format) (`./bin/a.out`, to do examples/[unit tests](https://wikipedia.org/wiki/Unit_test#Agile) which prove how effective functions execute,) both of which you can redirect with `export OBJDIR=___` (or `export BINDIR=___`.)
- [`./cxx/main.hxx`](https://github.com/SwuduSusuwu/SubStack/blob/trunk/cxx/main.hxx) has constants to use to interpret `a.out`'s return values.
Expand Down
3 changes: 2 additions & 1 deletion cxx/ClassCns.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#ifndef INCLUDES_cxx_ClassCns_cxx
#define INCLUDES_cxx_ClassCns_cxx
#include "ClassCns.hxx" /* CnsMode std::string std::tuple */
#include "Macros.hxx" /* SUSUWU_OVERRIDE */
#include <cassert> /* assert */
#include <cctype> /* size_t */
#include <cstdlib> /* exit EXIT_FAILURE */
Expand All @@ -15,7 +16,7 @@ namespace Susuwu {
#include <vector> /* std::vector */
typedef class HsomCns : Cns { /* TODO. ( https://stackoverflow.com/questions/3286448/calling-a-python-method-from-c-c-and-extracting-its-return-value ) suggests various syntaxes to use for this, with unanswered comments such as "Does this support classes?" */
//template<Input, Output> void setupSynapses(const std::vector<std::tuple<Input, Output>>) { /* TODO: templates not allowed for virtual functions with C++ ( https://stackoverflow.com/a/78440416/24473928 ), so must produce codes for each combination of inputMode+outputMode */
void setupSynapses(const std::vector<std::tuple<float, float>>) {
void setupSynapses(const std::vector<std::tuple<float, float>>) SUSUWU_OVERRIDE {
setenv("PYTHONPATH",".",1);
Py_Initialize();
// PyRun_SimpleString("import sys; sys.path.append('.')"); PyRun_SimpleString("import hsom; from hsom import SelfOrganizingNetwork;");
Expand Down
20 changes: 10 additions & 10 deletions cxx/ClassCns.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef INCLUDES_cxx_ClassCns_hxx
#define INCLUDES_cxx_ClassCns_hxx
#include "ClassObject.hxx" /* Object */
#include "Macros.hxx" /* SUSUWU_NOEXCEPT SUSUWU_CXX17 */
#include "Macros.hxx" /* SUSUWU_CXX17 SUSUWU_DEFAULT SUSUWU_NOEXCEPT SUSUWU_OVERRIDE */
#include <cassert> /* assert */
#include <cstddef> /* size_t */
#include <string> /* std::string */
Expand All @@ -24,15 +24,15 @@ typedef enum CnsMode : char {

typedef class Cns : Object {
public:
const std::string getName() const override {return "Susuwu::class Cns";}
~Cns() override = default;
Cns() = default; /* Default constructor */
Cns(const Cns &) = default; /* Copy constructor */
Cns& operator=(const Cns &) = default; /* Copy assignment */
Cns(Cns&&) SUSUWU_NOEXCEPT = default; /* Move constructor */
Cns& operator=(Cns &&) SUSUWU_NOEXCEPT = default; /* Move assignment */
const bool hasImplementation() const override {return typeid(Cns) != typeid(this);}
const bool isInitialized() const override {return initialized;}
const std::string getName() const SUSUWU_OVERRIDE {return "Susuwu::class Cns";}
~Cns() SUSUWU_OVERRIDE = SUSUWU_DEFAULT;
Cns() = SUSUWU_DEFAULT; /* Default constructor */
Cns(const Cns &) = SUSUWU_DEFAULT; /* Copy constructor */
Cns& operator=(const Cns &) = SUSUWU_DEFAULT; /* Copy assignment */
Cns(Cns&&) SUSUWU_NOEXCEPT = SUSUWU_DEFAULT; /* Move constructor */
Cns& operator=(Cns &&) SUSUWU_NOEXCEPT = SUSUWU_DEFAULT; /* Move assignment */
const bool hasImplementation() const SUSUWU_OVERRIDE {return typeid(Cns) != typeid(this);}
const bool isInitialized() const SUSUWU_OVERRIDE {return initialized;}
virtual void setInitialized(const bool is) {initialized = is;}
virtual void setInputMode(CnsMode x) {inputMode = x;}
virtual void setOutputMode(CnsMode x) {outputMode = x;}
Expand Down
6 changes: 3 additions & 3 deletions cxx/ClassObject.hxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */
#ifndef INCLUDES_cxx_ClassObject_hxx
#define INCLUDES_cxx_ClassObject_hxx
#include "Macros.hxx" /* SUSUWU_CXX20 */ /* NOLINT(misc-include-cleaner): if undefined, `clang-tidy` warns "unused" */
#include "Macros.hxx" /* SUSUWU_CXX20 SUSUWU_DEFAULT */ /* NOLINT(misc-include-cleaner): if undefined, `clang-tidy` warns "unused" */
#include <cassert> /* assert */
#include <cctype> /* size_t */
#include <cstring> /* memcmp */
Expand All @@ -17,10 +17,10 @@ typedef enum ObjectCloneAs : unsigned char {
} ObjectCloneAs;
typedef class Class { /* suppress `clang-tidy`'s suggestion of constructor (cannot have virtual constructor): NOLINT(cppcoreguidelines-special-member-functions, hicpp-special-member-functions) */
public:
virtual ~Class() = default; /* allow subclasses to release resources */
virtual ~Class() = SUSUWU_DEFAULT; /* allow subclasses to release resources */
/* `clang-tidy` off: NOLINTBEGIN(fuchsia-overloaded-operator, cppcoreguidelines-explicit-virtual-functions, hicpp-use-override,modernize-use-override) */
#ifdef SUSUWU_CXX20 /* TODO? `clang++` support this with C++17, but emits `-Wc++20-extensions`*/
virtual /* const requires C++26 */ bool operator==(const Class &) const = default;
virtual /* const requires C++26 */ bool operator==(const Class &) const = SUSUWU_DEFAULT;
#else /* !C++20 */
virtual /* const requires C++26 */ bool operator==(const Class &obj) const { return (sizeof(*this) == sizeof(obj) && 0 == memcmp(reinterpret_cast<const void *>(this), reinterpret_cast<const void *>(&obj), sizeof(*this))); } /* warning: first operand of this 'memcmp' call is a pointer to dynamic class 'Object'; vtable pointer will be compared [-Wdynamic-class-memaccess] */
#endif /* !(C++20 */
Expand Down
5 changes: 3 additions & 2 deletions cxx/ClassPortableExecutable.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#ifndef INCLUDES_cxx_ClassPortableExecutable_hxx
#define INCLUDES_cxx_ClassPortableExecutable_hxx
#include "ClassObject.hxx" /* Object */
#include "Macros.hxx" /* SUSUWU_OVERRIDE */
#include <fstream> /* std::ifstream */
#include <iterator> /* std::istreambuf_iterator */
#include <string> /* std::string */
Expand All @@ -16,7 +17,7 @@ typedef FilePath FileHash; /* TODO: `std::unordered_set<std::basic_string<unsign
typedef class PortableExecutable : Object {
/* TODO: union of actual Portable Executable (Microsoft) + ELF (Linux) specifications */
public:
const std::string getName() const override {return "Susuwu::class PortableExecutable";}
const std::string getName() const SUSUWU_OVERRIDE {return "Susuwu::class PortableExecutable";}
explicit PortableExecutable(FilePath path_ = "") : path(std::move(path_)) {}
PortableExecutable(FilePath path_, FileBytecode bytecode_) : path(std::move(path_)), bytecode(std::move(bytecode_)) {} /* TODO: NOLINT(bugprone-easily-swappable-parameters) */
/*TODO: overload on typedefs which map to the same types: PortableExecutable(const FilePath &path_, const std::string &hex_) : path(path_), hex(hex_) {} */
Expand All @@ -28,7 +29,7 @@ public:
} PortableExecutable;
typedef class PortableExecutableBytecode : public PortableExecutable {
public:
const std::string getName() const override {return "Susuwu::class PortableExecutableBytecode";}
const std::string getName() const SUSUWU_OVERRIDE {return "Susuwu::class PortableExecutableBytecode";}
explicit PortableExecutableBytecode(FilePath path_) : PortableExecutable(std::move(path_)) {std::ifstream input(path); if(input.good()) {bytecode = std::string(std::istreambuf_iterator<char>(input), std::istreambuf_iterator<char>());}}
} PortableExecutableBytecode;
}; /* namespace Susuwu */
Expand Down
4 changes: 2 additions & 2 deletions cxx/ClassResultList.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "ClassPortableExecutable.hxx" /* FilePath FileBytecode FileHash */
#include "ClassSha2.hxx" /* classSha2 */
#include "ClassSys.hxx" /* classSysHexOs */
#include "Macros.hxx" /* SUSUWU_NOEXCEPT SUSUWU_PREFER_CSTR */
#include "Macros.hxx" /* SUSUWU_NOEXCEPT SUSUWU_OVERRIDE SUSUWU_PREFER_CSTR */
#include <algorithm> /* std::search std::find std::set_intersection */
#include <cstddef> /* size_t */
#if SUSUWU_PREFER_CSTR
Expand All @@ -22,7 +22,7 @@ typedef FileBytecode ResultListBytecode; /* Should have structure of FileBytecod
typedef FilePath ResultListSignature; /* TODO: `typedef ResultListBytecode ResultListSignature; ResultListSignature("string literal");` */
typedef ptrdiff_t BytecodeOffset; /* all tests of `ResultListBytecode` should return `{BytecodeOffset, X}` (with the most common `X` as `ResultListHash` or `ResultListSignature`). `offset = -1` if no match */
typedef struct ResultList : Object { /* Lists of {metadata, executables (or pages)} */
const std::string getName() const override {return "Susuwu::struct ResultList";}
const std::string getName() const SUSUWU_OVERRIDE {return "Susuwu::struct ResultList";}
/* `clang-tidy` off: NOLINTBEGIN(misc-non-private-member-variables-in-classes) */
typedef std::unordered_set<ResultListHash> Hashes;
Hashes hashes; /* Checksums of executables (or pages); to avoid duplicates, plus to do constant ("O(1)") test for which executables (or pages) exists */
Expand Down
18 changes: 9 additions & 9 deletions cxx/ClassSys.cxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */
#ifndef INCLUDES_cxx_ClassSys_cxx
#define INCLUDES_cxx_ClassSys_cxx
#include "Macros.hxx" /* ERROR SUSUWU_ERRSTR SUSUWU_NOEXCEPT SUSUWU_POSIX SUSUWU_WARNING SUSUWU_WIN32*/
#include "Macros.hxx" /* ERROR SUSUWU_ERRSTR SUSUWU_NOEXCEPT SUSUWU_NULLPTR SUSUWU_POSIX SUSUWU_WARNING SUSUWU_WIN32*/
#include "ClassSys.hxx" /* classSysHexStr classSysHexOs */
#include <cassert> /* assert */
#include <cerrno> /* errno */
Expand All @@ -23,13 +23,13 @@ typedef int pid_t;
#include <vector> /* std::vector */
namespace Susuwu {
int classSysArgc = 0;
const char **classSysArgs = {nullptr};
const char **classSysArgs = {SUSUWU_NULLPTR};
const bool classSysInit(int argc, const char **args) {
classSysArgc = argc;
if(0 < argc) {
classSysArgs = args;
assert(nullptr != args);
assert(nullptr != args[0]); /* `clangtidy` off: NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) */
assert(SUSUWU_NULLPTR != args);
assert(SUSUWU_NULLPTR != args[0]); /* `clangtidy` off: NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) */
return true;
}
return false;
Expand All @@ -51,7 +51,7 @@ const pid_t execvesFork(const std::vector<std::string> &argvS, const std::vector
for(const auto &x: argvSmutable /* auto x = argvSmutable.cbegin(); argvSmutable.cend() != x; ++x */) {
argv.push_back(const_cast<char *>(x.c_str()));
}
argv.push_back(nullptr);
argv.push_back(SUSUWU_NULLPTR);
if(envpS.empty()) { /* Reuse LD_PRELOAD to fix https://github.com/termux-play-store/termux-issues/issues/24 */
execv(argv[0], &argv[0]); /* NORETURN */
} else {
Expand All @@ -61,7 +61,7 @@ const pid_t execvesFork(const std::vector<std::string> &argvS, const std::vector
for(const auto &x: envpSmutable) {
envp.push_back(const_cast<char *>(x.c_str()));
}
envp.push_back(nullptr);
envp.push_back(SUSUWU_NULLPTR);
execve(argv[0], &argv[0], &envp[0]); /* NORETURN */
}
exit(EXIT_FAILURE); /* execv*() is `NORETURN`. NOLINT(concurrency-mt-unsafe) */
Expand Down Expand Up @@ -123,9 +123,9 @@ const bool classSysSetRoot(bool root) {
# else /* !def linux */
uid_t sudoUid = getuid();
if(0 == sudoUid) {
char *sudoUidStr = getenv("SUDO_UID") /* NOLINT(concurrency-mt-unsafe) */, *sudoUidStrIt = nullptr;
if(nullptr == sudoUidStr) {
SUSUWU_WARNING("classSysSetRoot(false) {(nullptr == getenv(\"SUDO_UID\")) /* stuck as root */}");
char *sudoUidStr = getenv("SUDO_UID") /* NOLINT(concurrency-mt-unsafe) */, *sudoUidStrIt = SUSUWU_NULLPTR;
if(SUSUWU_NULLPTR == sudoUidStr) {
SUSUWU_WARNING("classSysSetRoot(false) {(SUSUWU_NULLPTR == getenv(\"SUDO_UID\")) /* stuck as root */}");
return true;
} else {
sudoUid = static_cast<uid_t>(strtol(sudoUidStr, &sudoUidStrIt, 10));
Expand Down
4 changes: 2 additions & 2 deletions cxx/ClassSys.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ extern int classSysArgc;
extern const char **classSysArgs;
/* Called from main(), stores {argc, args} into {classSysArgc, classSysArgs}
* Much simpler to use path from args[0] (versus https://stackoverflow.com/questions/1528298/get-path-of-executable/34109000#34109000)
* @pre @code (0 < argc && nullptr != args && nullptr != args[0]
* @post @code (0 < classSysArgc && nullptr != classSysArgs && nullptr != classSysArgs[0] */
* @pre @code (0 < argc && SUSUWU_NULLPTR != args && SUSUWU_NULLPTR != args[0]
* @post @code (0 < classSysArgc && SUSUWU_NULLPTR != classSysArgs && SUSUWU_NULLPTR != classSysArgs[0] */
const bool classSysInit(int argc, const char **args);

typedef decltype(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count()) ClassSysUSeconds;
Expand Down
19 changes: 18 additions & 1 deletion cxx/Macros.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,29 @@
#ifndef INCLUDES_cxx_Macros_cxx
#define INCLUDES_cxx_Macros_cxx
/* This is just unit tests. `Macros.hxx` has all which has actual use. */
#include "Macros.hxx" /* IF_SUSUWU_CPLUSPLUS SUSUWU_ASSUME SUSUWU_CONSTEXPR SUSUWU_EXPECTS SUSUWU_ENSURES SUSUWU_NOEXCEPT SUSUWU_NORETURN SUSUWU_STATIC_ASSERT SUSUWU_UNREACHABLE */
#include "Macros.hxx" /* IF_SUSUWU_CPLUSPLUS SUSUWU_ASSUME SUSUWU_CONSTEXPR SUSUWU_DEFAULT SUSUWU_DELETE SUSUWU_EXPECTS SUSUWU_ENSURES SUSUWU_FINAL SUSUWU_NOEXCEPT SUSUWU_NORETURN SUSUWU_NULLPTR SUSUWU_OVERRIDE SUSUWU_STATIC_ASSERT SUSUWU_UNREACHABLE */
#include IF_SUSUWU_CPLUSPLUS(<cstdlib>, <stdlib.h>) /* exit */
#ifdef SUSUWU_CXX11
# include <type_traits> /* is_empty */
SUSUWU_CONSTEXPR static const bool MacrosCxx11NullptrTest(decltype( NULL) /* `int` */) {return false;}
SUSUWU_CONSTEXPR static const bool MacrosCxx11NullptrTest(decltype(SUSUWU_NULLPTR) /* `void *` */) {return true;}
SUSUWU_STATIC_ASSERT(true == MacrosCxx11NullptrTest(SUSUWU_NULLPTR)); /* Tests that `nullptr` is `void *` */
#endif /* def SUSUWU_CXX11 */
namespace Susuwu { /* NOLINTBEGIN(misc-use-anonymous-namespace): can't use functions if anonymouse */
class MacrosCxx11InheritanceTest {
public:
virtual ~MacrosCxx11InheritanceTest() = SUSUWU_DEFAULT; /* Notice: destructor has implementation; reimplementation is optional. */
MacrosCxx11InheritanceTest() = SUSUWU_DELETE; /* Notice: deleted constructor is redundant for pure virtual class */
virtual const bool PureVirtual() const = 0; /* Notice: this is pure virtual; subclasses must implement this. */
};
class MacrosCxx11InheritanceTestSubclass : MacrosCxx11InheritanceTest {
public: /* Notice: inherits default constructor */
const bool PureVirtual() const SUSUWU_OVERRIDE {return true;}; /* Notice: `final` is not allowed since this has a subclass. `override` is optional. */
};
class MacrosCxx11InheritanceTestSubclass2 SUSUWU_FINAL /* Since destructor is final, cannot inherit from class. `clang++` thus warns, unless the whole class is `final`. */: MacrosCxx11InheritanceTestSubclass {
public: /* Notice: inherits `PureVirtual()`, which you can now set `final` */
~MacrosCxx11InheritanceTestSubclass2() SUSUWU_OVERRIDE SUSUWU_FINAL {}; /* Notice: `override`/`final` is optional. */
};
static void macrosNoUniqueAddressTest() {
typedef class Zero {} Zero;
class SubClassWithBaseSubobject : public Zero {bool boo;};
Expand Down
Loading

0 comments on commit 4920b4a

Please sign in to comment.