Dual licenses: choose Creative Commons or Apache 2 (allows all uses).
./posts/
stages posts (school classes) for https://SwuduSusuwu.SubStack.com/ about artificial neural tissue, antivirus, assistants, plus autonomous tools.
./c/
C implementations of posts (TODO, issue #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/
C++ implementations of posts (for now is just neural system pure virtual template (./cxx/ClassCns.hxx
) + antivirus(./cxx/VirusAnalysis.cxx
) + assistant(./cxx/AssistantCns.cxx
), with lots of issues which you can contribute to, or can request that more resources go to).
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 (all
CXX
with201102 <= __cplusplus
,) due to use ofauto
,class {bool defaultMemberInit = true};
,decltype
,for(value: list) {}
).- Other than those 4, most non-C++98 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
,[[no_unique_address]]
. - If you must have C99 support; ask for this (in issue #3), or contribute.
- If you must have C++98 support; ask for this (in issue #20), or contribute.
- Other than those 4, most non-C++98 features were replaced with
Usage: ./build.sh [OPTIONS]
produces objects (./obj/*.o
, for distribution into other tools,) plus Executable and Linkable Format (./bin/a.out
, to do examples/unit tests which prove how effective functions execute,) both of which you can redirect with export OBJDIR=___
(or export BINDIR=___
.)
./cxx/main.hxx
has constants to use to interpreta.out
's return values.- Console flags:
./build.sh
: Defaults to./build.sh --debug
. For all source code, if intermediate object doesn't exist or is older than source, builds source../build.sh --clean
: removes intermediate object files + exits; to reduce disc use../build.sh --rebuild
: removes intermediate object files + continues; to rebuild with new flags (or if./build.sh
doesn't rebuild code which includes updated headers)../build.sh --debug
: includes frame-pointers/debug symbols (-g
), includesvalgrind
-replacement tools (such as-fsanitize=address
), optimizes with-Og
../build.sh --release
: excludes--debug
(-DNDEBUG
), strips frame-pointers/symbols, optimizes with-O2
../build.sh --mingw
: can mix with--release
or--debug
. Produces Portable Executable (./bin/a.exe
), for Windows.
- Special flags (
vim build.sh
to use); other than_PREFER_
/_SKIP_
, most use more resources if set totrue
:- Custom
sh
(console) output:-DSUSUWU_SH_PREFER_STDIO
to replacestd::cXXX << ...
withfprintf(stdXXX, ...)
; default is!defined(__cplusplus)
.-DSUSUWU_SH_VERBOSE
to print diagnostic messages (SUSUWU_SH_USE_FILE
,SUSUEU_SH_USE_LINE
,SUSUWU_NOTICE
,SUSUWU_DEBUG
,SUSUWU_DEBUGEXECUTE
,SUSUWU_NOTICE_EXECUTE
,SUSUWU_DEBUG_EXECUTE
all use#if SUSUWU_SH_VERBOSE
); default is!defined(NDEBUG)
.-DSUSUWU_SH_SKIP_BRACKETS = true
sets output format toWARN_LEVEL: message
; default isfalse
.-DSUSUWU_SH_FILE = true
sets output format to[__FILE__: WARN_LEVEL: message]
; default isSUSUWU_SH_VERBOSE
.-DSUSUWU_SH_LINE = true
sets output format to[__LINE__: WARN_LEVEL: message]
; default isSUSUWU_SH_VERBOSE
.-DSUSUWU_SH_FUNC = true
sets output format to[__func__: WARN_LEVEL: message]
; default isfalse
.-DSUSUWU_SH_SKIP_COLORS = true
to omit VT100 (ANSI) colors; default isdefined(SUSUWU_SH_COLORS_UNSUPPORTED)
).-DSUSUWU_SH_SKIP_COLORS = false
to force (even if unsupported) VT100 (ANSI) color use.- Flags which #17 will introduce (TODO):
-DSUSUWU_SH_RUNTIME_OSC
to replace#ifdef _POSIX_VERSION\nAccessClipboard();\n#endif
withtermcmp
/GetConsoleMode()
(for choices on whether or not to use Operating System Commands); default is undefined.-DSUSUWU_SH_RUNTIME_COLORS
to replace#if _POSIX_VERSION\nColors();\n#endif
withtermcmp
/GetConsoleMode()
(for choices on whether or not to use colors); default is undefined.
- To match
g++
/clang++
console format, use-DSUSUWU_SKIP_BRACKETS = true, -DSUSUWU_SH_FILE = true, -DSUSUWU_SH_LINE = true, -DSUSUWU_SH_FUNC = false, -DSUSUWU_SKIP_COLORS = false
(sets output format to__FILE__:__LINE__: WARN_LEVEL: message
). - TODO:
-DSUSUWU_PREFER_CSTR
to replacestd::string
withchar *
(more compatible with non-C++ projects); default isfalse
.-DSUSUWU_PREFER_C
setsSUSUWU_PREFER_CSTR
+SUSUWU_SH_PREFER_STDIO
(plus other flags which will exist to allow non-C++ projects to include this; default isfalse
.
- Custom
Linter: clang-tidy cxx/*.cxx
/* uses .clang-tidy
options */
Do atomic commits: if you cannot ./build.sh
your commit if it is swapped (such as through git rebase -i
) with a previous commit, or cannot ./build.sh
if a previous commit got git revert
, your commit message must include such as "Is followup to <commit hash>" (which shows temporal order).
git commit
message format/syntax:
- if commit does
git add NewFile
: message has+\
NewFile``. - if
git rm Exists
:-
Exists``. - if
touch Exists && git add Exists
:@\
Exists`or
?`Exists``.- Simple wildcards/regex for altered functions:
\
%s/oldFunction/newFunction/``.
- Simple wildcards/regex for altered functions:
- if
echo "int newFunction() {...}" >> Exists && git add Exists
:@\
Exists`:+`NewFunction()``. - if
git mv OldPath/ NewPath/
:\
OldPath/.* -> NewPath/.*``.
[Notice: Commit titles can omit backticks (``) if not enough room; the backticks just allow GitHub to format code/paths.]
Most of what Mozilla Org's (Firefox's) style suggests is sound (you should follow this unless you have specific reasons not to). Code rules (lots overlap with Mozilla Org's):
-
Files:
#include "PascalCase.hxx"
, as this is most common../build.sh
requires: that all local includes prefix asClass*.hxx
(so it knows to execute--rebuild
if you upgrade a common include.) TODO: incremental builds which don't require this. -
Structs, enums, classe:
typedef struct PascalCase {} PascalCase;
,typedef enum PascalCase {} PascalCase;
,typedef class PascalCase {} PascalCase;
, as this is most common. -
Macros:
#define NAMESPACE_CONSTANT_CASE(snake_case_param) assert(snake_case_param);
, as this is most common. -
Indent: tabs ('^I', reduced memory use, allows local configs to set width, allows arrow keys to move fast); as much tabs as braces ('{', '}'). [All which conflicts with Mozilla Org's format is tab use.]
-
Braces, functions; most common form:
const /* const prevents `if(func() = x)` where you wished for `if(func() == x)` */ bool classPrefixCamelCase(bool s, bool x) {
if(s && x) {
return s;
} else {
return x;
}
}
-
Local variables, objects:
const bool camelCase = true
; Global variables/objects:extern const bool classPrefixCamelCase;
, as this is most common.- Functions/globals can omit "classPrefix" if the file has
namespace
used to avoid collisions, or hasclass
used to mask membertypedef
s/functions. - [The project as a whole should have
namespace
, but you can nestnamespace
s.]
- Functions/globals can omit "classPrefix" if the file has
-
Include guards:
#ifndef INCLUDES_Path_To_File
#define INCLUDES_Path_To_File
#endif /* ndef INCLUDES_Path_To_File */
- Indent multi-level macros as
#if X # if S ,,, # endif #endif
- _DEBUG is specific to MSVC, thus use NDEBUG, Pass
-D NDEBUG
to disable asssets + enable optimizations - Do not perform tasks within
assert()
, due to: the standard says "[#if NDEBUG\n#define assert(x) (0)\n#endif
]". - All userland errors should go to
throw std::exception()
or derivatives of std::exception,std::cerr
,extern int errno;
, orreturn errno;
. Comments about possible errors should go above function declarations (Doxygen convention).throw
/std:cerr
should use the new common syntax for this:"[WARN_LEVEL: OPTIONAL_FUNCTION_NAME {code which triggered the error/warning/diagnostic/notice} /* OPTIONAL COMMENTS */]"
,./cxx/Macros.hxx
: {SUSUWU_STR(x), SUSUWU_CERR(x), SUSUWU_STDOUT(x)} have the new syntax for this.
- Doxygen-ish "@pre"/"@post" prepares for C++26 Contracts:
/* @throw std::bad_alloc If function uses {malloc, realloc, new[], std::*::{push_back, push_front, insert}}
* @throw std::logic_error Optional. Would include most functions which use std::*
* @pre @code !output.full() @endcode
* @post @code !output.empty() @endcode
*/
bool functionDeclaration(std::string input, std::deque<vector> output);
- It is arguable whether or not you should document such possible system errors; almost all Standard Template Library functions can throw derivatives of
std::logic_error
. - Regex
:%s/@pre (.*) @code (.*) @endcode/[[expects: \2]] \\* \1 \\*/
:%s/@post (.*) @code (.*) @endcode/[[ensures: \2]] \\* \1 \\*/
once have Contracts/C++26. - cxx/Macros.cxx has
ASSUME(X)
, which is close to[[expects: x]]
, butASSUME(X)
goes to*.cxx
, whereas[[expects]]
goes to*.hxx
. - Documentation of interfaces belongs to
*.hxx
;*.cxx
is to do implementations. Do not duplicate interface comments. - Advantages of
[[expects]]
; allows to move information of interfaces out of*.cxx
, to*.hxx
.