Repository navigation
libc-m 17.0.0: the C standard library's macros for C++ modules (mcpplibs.mwrap.libc) - #1
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The C standard library as C++23 modules:
mcpplibs.mwrap.libc17.0.0 maps the object-like macros of ISO C17 thatstd.compatcannot export (a named module exports no macro). mcpp 2026.11.7.1, mcpp-plugins and the language server readstdout,stderr,EOF,BUFSIZanderrnofrom 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 asinline constexpr; the rest as constexpr functions returning the macro's expression (errno()isint&,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>forassert,setjmp,va_*,offsetof,INTn_C.std::errc),NULL, C-only headers, keyword macros, classification macros,__STDC_*, Annex K.[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.stdout()/stderr(), readerrno()as set bystrtol, use the stdio constants, call the function-like macros, compare every mapping with its macro, and mix the header with the module. Default templatestdio.Local results (Linux x86_64)
mcpp test, GCC 16.1.0 / LLVM 23.1.3 /--target x86_64-linux-musl/--target x86_64-openkal --platform openkal-platform@0.24.0tools/generate.py --checktools/test_template.pytools/check_mwrap_release.pymcpplibs.mwrap.libc@17.0.0After merge: tag
mwrap-17.0.0, GitCode mirror, mcpp-indexpkgs/mwrap/libc.lua,tests/mwrap/libc, and the sentence indocs/mwrap.mdthat the C standard library's implementation is the target's C library.