Skip to content

libc-m 17.0.0: the C standard library's macros for C++ modules (mcpplibs.mwrap.libc) - #1

Merged
Sunrisepeak merged 2 commits into
mainfrom
mwrap-17.0.0
Nov 6, 2026
Merged

Sunrisepeak merged 2 commits into
mainfrom
mwrap-17.0.0

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

The C standard library as C++23 modules: mcpplibs.mwrap.libc 17.0.0 maps the object-like macros of ISO C17 that std.compat cannot export (a named module exports no macro). mcpp 2026.11.7.1, mcpp-plugins and the language server read stdout, stderr, EOF, BUFSIZ and errno from it instead of including C headers for their macros (mcpp design record 2026-11-07, D10, §4.4.1).

Contents

  • mcpplibs.mwrap.libc: export import std.compat; and the macros module.
  • mcpplibs.mwrap.libc.macros: every object-like macro of ISO C17 Annex B that the target defines (tools/iso_c.toml, 334 names; 331 on glibc): 315 constant expressions as inline constexpr; the rest as constexpr functions returning the macro's expression (errno() is int&, stdout() the stream, MB_CUR_MAX()); eight that are constants only with some C libraries take the function form everywhere (tools/surface.toml). Each mapping exists where the target defines the macro (#ifdef).
  • <mwrap/libc/macros.hpp>: includes <assert.h>, <setjmp.h>, <stdarg.h>, <stddef.h>, <stdint.h> for assert, setjmp, va_*, offsetof, INTn_C.
  • Not mapped, with reasons (docs/usage.md): POSIX error numbers (std::errc), NULL, C-only headers, keyword macros, classification macros, __STDC_*, Annex K.
  • Version 17.0.0 names ISO/IEC 9899:2018, which C++23 references; [package.metadata.mwrap] records the standard and that the implementation is the target's C library. The release check accepts a standard as upstream without retained documents.
  • CI: glibc with libstdc++ and libc++, musl, openkal-musl under okrun, macOS libSystem, the Windows CRT with libc++ and the MSVC STL, mingw-w64. Tests write through stdout()/stderr(), read errno() as set by strtol, use the stdio constants, call the function-like macros, compare every mapping with its macro, and mix the header with the module. Default template stdio.

Local results (Linux x86_64)

Check Result
mcpp test, GCC 16.1.0 / LLVM 23.1.3 / --target x86_64-linux-musl / --target x86_64-openkal --platform openkal-platform@0.24.0 3/3 passed each; 331 macros mapped, 0 differ
tools/generate.py --check 0 problems
tools/test_template.py template built and ran
tools/check_mwrap_release.py mcpplibs.mwrap.libc@17.0.0

After merge: tag mwrap-17.0.0, GitCode mirror, mcpp-index pkgs/mwrap/libc.lua, tests/mwrap/libc, and the sentence in docs/mwrap.md that the C standard library's implementation is the target's C library.

Sunrisepeak and others added 2 commits November 7, 2026 06:30
…ibs.mwrap.libc)

Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
… C library

The Windows CRT's <stddef.h> defines errno and macOS's headers bring
MB_CUR_MAX and NAN, so a unit that included the header could not name the
mapped constants there. tools/generate.py now writes the header from
tools/iso_c.toml with every object-like macro of the list undefined after the
includes.

Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
@Sunrisepeak
Sunrisepeak merged commit dd1e5eb into main Nov 6, 2026
9 checks passed
@Sunrisepeak
Sunrisepeak deleted the mwrap-17.0.0 branch November 6, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant