// SPDX-License-Identifier: GPL-3.0-or-later #include // Separate tag and typedef namespaces, with values whose representation differs. typedef unsigned Ledger; struct Ledger { unsigned value; }; enum Route { HOME_ROUTE = 1003 }; typedef enum Route RouteAlias; // CMOC's octal parser requires an initial \0; \103 is not supported. static const char globalEscapes[] = "\x41" "B\0103"; static unsigned char runtimeIndex; static unsigned receiveRoute(enum Route route) { return (unsigned) route + 13; } int main(void) { Ledger scalar = 0x1234; struct Ledger record = { 0x5678 }; char localEscapes[] = "\0101\0102\x43"; unsigned char inferred[sizeof("\x41" "B\0103")]; struct { unsigned char before; char text[4]; unsigned char after; } guarded = { 0x55, "\x41" "B\0103", 0xaa }; printf("LANG %04X%04X %04X%04X ", receiveRoute((enum Route) 1003), receiveRoute((RouteAlias) 2003), scalar, record.value); printf("%u%u%u ", (unsigned) sizeof(globalEscapes), (unsigned) sizeof(localEscapes), (unsigned) sizeof(inferred)); // Include actual bytes and sentinels. Host owns the expected values, not // the same compiler expression that produced the tested initializer. for (runtimeIndex = 0; runtimeIndex < sizeof(globalEscapes); ++runtimeIndex) printf("%02X", (unsigned char) globalEscapes[runtimeIndex]); printf(" "); for (runtimeIndex = 0; runtimeIndex < sizeof(localEscapes); ++runtimeIndex) printf("%02X", (unsigned char) localEscapes[runtimeIndex]); printf(" %02X", guarded.before); for (runtimeIndex = 0; runtimeIndex < sizeof(guarded.text); ++runtimeIndex) printf("%02X", (unsigned char) guarded.text[runtimeIndex]); printf("%02X END\n", guarded.after); return 0; }