Skip to content

Libc: use standard type names where possible - #578

Closed
chqrlie wants to merge 1 commit into
c2lang:masterfrom
chqrlie:time_t
Closed

chqrlie wants to merge 1 commit into
c2lang:masterfrom
chqrlie:time_t

Conversation

@chqrlie

@chqrlie chqrlie commented Oct 14, 2026

Copy link
Copy Markdown
Contributor
  • use familiar time_t, off_t, pid_t...
  • remove __ prefixes from library function argument names

* use familiar `time_t`, `off_t`, `pid_t`...
* remove `__` prefixes from library function argument names
@bvdberg

bvdberg commented Oct 15, 2026

Copy link
Copy Markdown
Member

This will require some discussion. What I liked in the current situation is that it keep the C2 model of user-types correct, they all start with a Capital. Using time_t drags in the old (anti) pattern of _t to indicate some type and breaks the naming. So I would rather pull libc forward, instead of letting it drag C2 backwards..

@chqrlie

chqrlie commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

I understand your goal, but I'm afraid redefining all legacy types is a real obstacle to adoption.

C2 is supposed to be an evolution of C, not a revolution. Renaming legacy types goes against 2 of the documented goals:

  • Easy integration with C libraries
  • Should be easy to learn for C programmers

Smooth integration with C libraries is already very challenging, and may ultimately require parsing the existing header files, which means using the existing type names.

Changing common type names makes C2 harder to use for experienced programmers and harder to port existing programs to.

I also don't really agree that time_t should be considered an anti-pattern: the suffix is a bit obnoxious but conveys the meaning quite effectively. I like u32 much better than uint32_t, because of the simplicity, but pid_t and off_t are simple enough.

Also these legacy types are not user types, but standard types and system types. user types are still restricted in their naming scheme.

The case of struct tm or worse struct stat is more problematic, but there are possible solutions:

  • I am contemplating struct_tm and struct_stat instead of Tm and Stat as a simpler conversion conveying their legacy nature.
  • it would also be possible to use the C syntax for these wherever they are used without conflicting with the C2 grammar.

@chqrlie chqrlie closed this Oct 17, 2026
@chqrlie
chqrlie deleted the time_t branch October 17, 2026 05:26
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.

2 participants