C to C++ migration and refactoring #17

Merged
harraiken merged 67 commits from cxxtest into master 2025-09-24 20:18:35 +02:00
Owner

Proposed changes

  • Migrated the entire existing codebase from C to C++
  • Added extern "C" wrappers for all exported functions to ensure full C API compatibility
  • Adapted XTDK to work seamlessly with both C and C++ code
  • Performed extensive refactoring:
    • reorganized variables and functions into classes
    • added initializers and getters/setters to ensure proper data encapsulation
  • Reworked libxtos:
    • now built from the entire kernel code
    • optimized to avoid being fully statically linked with the bootloader
  • Extended the SDK packaging:
    • the entire SDK is now installed and archived
    • includes not only compiled libraries but also headers necessary to build code against the kernel

Agreements

  • I have read the Contributors License Agreement and I consent to those terms.
## Proposed changes - Migrated the entire existing codebase from C to C++ - Added extern "C" wrappers for all exported functions to ensure full C API compatibility - Adapted XTDK to work seamlessly with both C and C++ code - Performed extensive refactoring: - reorganized variables and functions into classes - added initializers and getters/setters to ensure proper data encapsulation - Reworked libxtos: - now built from the entire kernel code - optimized to avoid being fully statically linked with the bootloader - Extended the SDK packaging: - the entire SDK is now installed and archived - includes not only compiled libraries but also headers necessary to build code against the kernel ## Agreements - [x] I have read the Contributors License Agreement and I consent to those terms.
harraiken added 64 commits 2025-09-22 15:08:36 +02:00
Migrate AR subsystem to C++
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 24s
Builds / ExectOS (amd64, release) (push) Failing after 27s
Builds / ExectOS (i686, debug) (push) Failing after 24s
Builds / ExectOS (i686, release) (push) Failing after 24s
c8dc2a1407
Fix cmake source path
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 27s
Builds / ExectOS (amd64, release) (push) Failing after 25s
Builds / ExectOS (i686, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 30s
4e24b239a4
Remove leftover test code
All checks were successful
Builds / ExectOS (i686, release) (push) Successful in 28s
Builds / ExectOS (amd64, release) (push) Successful in 24s
Builds / ExectOS (amd64, debug) (push) Successful in 34s
Builds / ExectOS (i686, debug) (push) Successful in 33s
3f5f57ef12
Migrate EX subsystem to C++
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 23s
Builds / ExectOS (i686, debug) (push) Failing after 23s
Builds / ExectOS (amd64, debug) (push) Failing after 25s
Builds / ExectOS (i686, release) (push) Failing after 23s
7c5d6326f8
Sync CMakeLists with current source tree
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 32s
Builds / ExectOS (amd64, debug) (push) Successful in 35s
Builds / ExectOS (i686, debug) (push) Successful in 32s
Builds / ExectOS (i686, release) (push) Successful in 30s
465a23633e
Migrate KE subsystem to C++
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 23s
Builds / ExectOS (amd64, release) (push) Failing after 27s
Builds / ExectOS (i686, debug) (push) Failing after 21s
Builds / ExectOS (i686, release) (push) Failing after 25s
4947f788d5
Sync CMakeLists with source tree
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 28s
Builds / ExectOS (amd64, debug) (push) Failing after 19s
Builds / ExectOS (i686, debug) (push) Failing after 19s
Builds / ExectOS (i686, release) (push) Failing after 25s
5cb6474ade
Include new KE headers
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 20s
Builds / ExectOS (amd64, debug) (push) Failing after 27s
Builds / ExectOS (i686, release) (push) Failing after 25s
Builds / ExectOS (i686, debug) (push) Failing after 20s
17712883c5
Add missing forward reference to KeGetInitializationBlock
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 36s
Builds / ExectOS (amd64, release) (push) Successful in 33s
Builds / ExectOS (i686, debug) (push) Successful in 30s
Builds / ExectOS (i686, release) (push) Successful in 29s
510dccc5dc
Clean up cmake output directory configuration
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 49s
Builds / ExectOS (amd64, release) (push) Successful in 47s
Builds / ExectOS (i686, debug) (push) Successful in 26s
Builds / ExectOS (i686, release) (push) Successful in 24s
e507dd0390
Migrate RTL subsystem to C++
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 21s
Builds / ExectOS (amd64, release) (push) Failing after 20s
Builds / ExectOS (i686, debug) (push) Failing after 19s
Builds / ExectOS (i686, release) (push) Failing after 18s
9518e7da8e
Improve CMake SDK output handling and linker configuration
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 20s
Builds / ExectOS (amd64, release) (push) Failing after 19s
Builds / ExectOS (i686, debug) (push) Failing after 19s
Builds / ExectOS (i686, release) (push) Failing after 18s
c160e5ddf2
Unify sdk library output path
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 19s
Builds / ExectOS (amd64, release) (push) Failing after 18s
Builds / ExectOS (i686, debug) (push) Failing after 20s
Builds / ExectOS (i686, release) (push) Failing after 19s
7674196cc1
Remove redundant source list and reuse XTOSKRNL_SOURCE for libxtos
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 21s
Builds / ExectOS (amd64, release) (push) Failing after 20s
Builds / ExectOS (i686, debug) (push) Failing after 21s
Builds / ExectOS (i686, release) (push) Failing after 20s
7d5eab1a8e
Add missing header files
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 22s
Builds / ExectOS (amd64, release) (push) Failing after 20s
Builds / ExectOS (i686, debug) (push) Failing after 24s
Builds / ExectOS (i686, release) (push) Failing after 23s
0a3450f649
Clean up atomic routine declarations
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 20s
Builds / ExectOS (amd64, debug) (push) Failing after 21s
Builds / ExectOS (i686, debug) (push) Failing after 22s
Builds / ExectOS (i686, release) (push) Failing after 20s
744fffdd8a
Match renamed I/O register helpers
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 21s
Builds / ExectOS (amd64, debug) (push) Failing after 23s
Builds / ExectOS (i686, debug) (push) Failing after 20s
Builds / ExectOS (i686, release) (push) Failing after 20s
3395934330
Update EX subsystem to use C++ RTL api
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 21s
Builds / ExectOS (amd64, release) (push) Failing after 19s
Builds / ExectOS (i686, debug) (push) Failing after 23s
Builds / ExectOS (i686, release) (push) Failing after 21s
1357e92627
Update SpinLock and DPC to use C++ helpers
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 22s
Builds / ExectOS (amd64, debug) (push) Failing after 23s
Builds / ExectOS (i686, debug) (push) Failing after 22s
Builds / ExectOS (i686, release) (push) Failing after 20s
631c260280
Update kernel exports
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 28s
Builds / ExectOS (amd64, release) (push) Successful in 26s
Builds / ExectOS (i686, debug) (push) Failing after 22s
Builds / ExectOS (i686, release) (push) Failing after 21s
cc632c5ef9
Fix calling conventions
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 28s
Builds / ExectOS (i686, release) (push) Successful in 26s
5f44458e64
Build SDK
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 31s
Builds / ExectOS (amd64, debug) (push) Successful in 33s
Builds / ExectOS (i686, release) (push) Successful in 26s
Builds / ExectOS (i686, debug) (push) Successful in 28s
96043f3d70
Refactor AR subsystem
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 33s
Builds / ExectOS (amd64, release) (push) Successful in 31s
Builds / ExectOS (i686, debug) (push) Successful in 32s
Builds / ExectOS (i686, release) (push) Successful in 32s
3a11d536d5
Migrate PO subsystem to C++
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 36s
Builds / ExectOS (amd64, release) (push) Successful in 33s
Builds / ExectOS (i686, release) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 29s
0647b853a6
Refactor KE subsystem
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 30s
Builds / ExectOS (amd64, debug) (push) Successful in 31s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 28s
7cdfa8f79d
Refine formatting
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 30s
Builds / ExectOS (amd64, debug) (push) Successful in 32s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 27s
a2fe39defd
Migrate HL subsystem to C++
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 27s
4592955da1
Migrate KD subsystem to C++
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 32s
Builds / ExectOS (amd64, release) (push) Successful in 31s
Builds / ExectOS (i686, debug) (push) Successful in 28s
Builds / ExectOS (i686, release) (push) Successful in 26s
79ec28641a
Refine and export kernel debugger printing
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 26s
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 30s
Builds / ExectOS (i686, release) (push) Successful in 28s
f321ca908b
Move dbg.hh into KD namespace
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 27s
Builds / ExectOS (amd64, release) (push) Successful in 26s
Builds / ExectOS (i686, release) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 29s
e0844b38cd
Add stubs for C++ exception and purecall handlers
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 35s
Builds / ExectOS (amd64, debug) (push) Successful in 37s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 28s
3e097c260d
Migrate MM subsystem to C++
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 24s
Builds / ExectOS (amd64, release) (push) Failing after 23s
Builds / ExectOS (i686, debug) (push) Failing after 22s
Builds / ExectOS (i686, release) (push) Failing after 21s
404595801d
Complete MM class definitions with missing fields
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 23s
Builds / ExectOS (amd64, release) (push) Failing after 22s
Builds / ExectOS (i686, release) (push) Failing after 21s
Builds / ExectOS (i686, debug) (push) Failing after 23s
52c4d2a346
Refactor kernel to use MM namespace for memory management
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 31s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 31s
Builds / ExectOS (i686, release) (push) Successful in 29s
e3898f28fc
Clean up kernel headers
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Failing after 21s
Builds / ExectOS (i686, release) (push) Failing after 20s
0a0fdffc46
Switch i686 processor structures setup to use class data
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 26s
Builds / ExectOS (amd64, debug) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 28s
Builds / ExectOS (i686, release) (push) Successful in 26s
ee97388981
Remove leftover old headers and fix missed spots
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 20s
Builds / ExectOS (amd64, debug) (push) Failing after 21s
Builds / ExectOS (i686, debug) (push) Failing after 21s
Builds / ExectOS (i686, release) (push) Failing after 19s
f4561c1f4f
Restore missing assembly headers
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 23s
Builds / ExectOS (amd64, release) (push) Failing after 21s
Builds / ExectOS (i686, debug) (push) Failing after 23s
Builds / ExectOS (i686, release) (push) Failing after 21s
556e832056
Replace legacy thread retrieval function calls
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 30s
Builds / ExectOS (amd64, debug) (push) Successful in 31s
Builds / ExectOS (i686, release) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 29s
2f25107d09
Add missing documentation and fix formatting
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 27s
f86b63f68d
Clean up after migration to C++
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 30s
307ec1794c
Migrate NTOSDRV to C++
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 31s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 30s
Builds / ExectOS (i686, release) (push) Successful in 28s
ba9e5b1b88
Replace all occurrences of NULL with NULLPTR for unified C and C++ null pointer handling
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 24s
Builds / ExectOS (amd64, debug) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 27s
Builds / ExectOS (i686, release) (push) Failing after 25s
fabf3a3a5e
Replace remaining NULL occurrence with NULLPTR
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 28s
98ad2087de
Switch UEFI interfaces to PWCHAR/BOOLEAN types for better compatibility with C++
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 32s
Builds / ExectOS (amd64, debug) (push) Successful in 34s
Builds / ExectOS (i686, release) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 32s
7117d76842
Migrate XTLDR to C++
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 29s
Builds / ExectOS (amd64, debug) (push) Successful in 31s
Builds / ExectOS (i686, debug) (push) Successful in 31s
Builds / ExectOS (i686, release) (push) Successful in 29s
86fd2b4eea
Remove stale comments and whitespace
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (i686, debug) (push) Successful in 30s
Builds / ExectOS (i686, release) (push) Successful in 29s
57fbbf820c
Migrate XTLDR modules to C++
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 31s
Builds / ExectOS (amd64, debug) (push) Successful in 33s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 27s
dcae0cbb91
Migrate XTOS module to C++
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 34s
Builds / ExectOS (amd64, release) (push) Successful in 33s
Builds / ExectOS (i686, debug) (push) Successful in 31s
Builds / ExectOS (i686, release) (push) Successful in 30s
9bbac6d3c1
Use new C++ API
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 30s
Builds / ExectOS (i686, release) (push) Successful in 28s
b2c8fa3e62
Drop C wrappers and switch to C++ API
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 36s
Builds / ExectOS (amd64, release) (push) Successful in 34s
Builds / ExectOS (i686, debug) (push) Failing after 23s
Builds / ExectOS (i686, release) (push) Failing after 21s
e7425de523
Fix build by replacing leftover Ar calls
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 31s
Builds / ExectOS (amd64, release) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Failing after 21s
Builds / ExectOS (i686, release) (push) Failing after 20s
1b0468f742
Fix build by replacing leftover Ar calls
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Failing after 24s
Builds / ExectOS (i686, release) (push) Failing after 23s
4c380bae1c
Fix build after migration
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, release) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 32s
7b357ebc54
Move asm headers
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 27s
d0577611ca
Add missing calling convention
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (i686, release) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 29s
38f1af025c
Add trampoline support and move assembler prototypes
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Failing after 24s
Builds / ExectOS (i686, release) (push) Failing after 22s
2b49b23d41
Fix AP startup symbol name
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 30s
Builds / ExectOS (i686, release) (push) Successful in 28s
ae4b95380a
Move trampoline handling code
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 29s
Builds / ExectOS (amd64, debug) (push) Successful in 31s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 28s
08a9a0273f
Refactor bootloader code into C++ classes
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 29s
Builds / ExectOS (amd64, release) (push) Failing after 27s
Builds / ExectOS (i686, debug) (push) Failing after 22s
Builds / ExectOS (i686, release) (push) Failing after 21s
c041457799
Unify XTLDR naming
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 31s
d0aeaf1109
Partially move global variables into classes
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 28s
Builds / ExectOS (amd64, release) (push) Successful in 26s
Builds / ExectOS (i686, debug) (push) Successful in 28s
Builds / ExectOS (i686, release) (push) Successful in 26s
7791ca13e2
Finish moving global variables into classes
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 34s
Builds / ExectOS (amd64, release) (push) Successful in 33s
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 27s
ed293c7e61
Document XTLDR methods
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (i686, release) (push) Successful in 27s
Builds / ExectOS (i686, debug) (push) Successful in 28s
6c66028800
harraiken requested review from belliash 2025-09-22 15:09:03 +02:00
belliash reviewed 2025-09-23 16:33:58 +02:00
xtldr/debug.cc Outdated
@@ -0,0 +398,4 @@
BOOLEAN
Debug::SerialPortReady()
{
return (BOOLEAN)(SerialPort.Flags & COMPORT_FLAG_INIT);
Owner

Do we need to typecast each bool operation? In C this returned integer value and compiler knew how to cast it into our BOOLEAN enum. In C++, result value is of bool type that cannot be automatically typecasted into enum.

Do we need to typecast each bool operation? In C this returned integer value and compiler knew how to cast it into our BOOLEAN enum. In C++, result value is of bool type that cannot be automatically typecasted into enum.
Author
Owner

No, we do not have to. Alternatively, I can suggest moving the BOOLEAN type definition from xttypes.h to xtcompat.h:

#ifdef __cplusplus
    /* C++ definitions */
    #define XTCLINK         extern "C"
    #define NULLPTR         nullptr

    /* C++ boolean type */
    typedef bool BOOLEAN, *PBOOLEAN;
    #define TRUE true
    #define FALSE false

    /* C++ widechar type */
    typedef wchar_t wchar;
#else
    /* C definitions */
    #define XTCLINK
    #define NULLPTR         ((void *)0)

    /* C boolean type */
    typedef enum _BOOLEAN
    {
        FALSE = 0,
        TRUE = 1
    } BOOLEAN, *PBOOLEAN;

    /* C widechar type */
    typedef unsigned short wchar;
#endif

This will allow us to maintain backward compatibility with C and get rid of explicit typecasts at the same time.
This should also work in the case of the quoted fragment, even though the result of the operation is not of type bool but int. The result of the expression will be 0 if the flag is not set, or the value of COMPORT_FLAG_INIT if it is. It is only the comparison of this result, for example (SerialPort.Flags & COMPORT_FLAG_INIT) != 0, that actually yields a bool type.

Please let me know if you accept this, then I will commit the proposed change.

No, we do not have to. Alternatively, I can suggest moving the BOOLEAN type definition from xttypes.h to xtcompat.h: ``` #ifdef __cplusplus /* C++ definitions */ #define XTCLINK extern "C" #define NULLPTR nullptr /* C++ boolean type */ typedef bool BOOLEAN, *PBOOLEAN; #define TRUE true #define FALSE false /* C++ widechar type */ typedef wchar_t wchar; #else /* C definitions */ #define XTCLINK #define NULLPTR ((void *)0) /* C boolean type */ typedef enum _BOOLEAN { FALSE = 0, TRUE = 1 } BOOLEAN, *PBOOLEAN; /* C widechar type */ typedef unsigned short wchar; #endif ``` This will allow us to maintain backward compatibility with C and get rid of explicit typecasts at the same time. This should also work in the case of the quoted fragment, even though the result of the operation is not of type bool but int. The result of the expression will be 0 if the flag is not set, or the value of COMPORT_FLAG_INIT if it is. It is only the comparison of this result, for example (SerialPort.Flags & COMPORT_FLAG_INIT) != 0, that actually yields a bool type. Please let me know if you accept this, then I will commit the proposed change.
Owner

You are right, this results in int, not bool. There are more such changes like this in the diff, and I added a comment to the first one, as its the only one that fits on first page. unfortunately. Never mind, I think the proposed solution will be OK.

You are right, this results in int, not bool. There are more such changes like this in the diff, and I added a comment to the first one, as its the only one that fits on first page. unfortunately. Never mind, I think the proposed solution will be OK.
belliash marked this conversation as resolved
harraiken added 1 commit 2025-09-23 19:06:35 +02:00
Separate boolean definition for C and C++
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (amd64, release) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 30s
Builds / ExectOS (i686, release) (push) Successful in 27s
9298aef87e
harraiken added 1 commit 2025-09-23 19:17:59 +02:00
Drop unnecessary boolean casts after type refactor
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 30s
Builds / ExectOS (amd64, release) (push) Successful in 28s
Builds / ExectOS (i686, debug) (push) Successful in 28s
Builds / ExectOS (i686, release) (push) Successful in 26s
6e10089280
harraiken added 1 commit 2025-09-23 22:54:52 +02:00
Update readme to reflect C++ namespaces and class-based naming
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 27s
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (i686, debug) (push) Successful in 28s
Builds / ExectOS (i686, release) (push) Successful in 26s
20fd950ef4
belliash approved these changes 2025-09-24 14:26:49 +02:00
harraiken merged commit ff0caf93da into master 2025-09-24 20:18:35 +02:00
Sign in to join this conversation.
No description provided.