Questions tagged [c23]
The c23 tag has no usage guidance.
19
questions
3
votes
0
answers
133
views
Copy a file portably across UNIX and UNIX-like systems with POSIX API (modeled after Boost's copy_file())
Overview:
Following the POSIX API, there are 2 versions of the function: unix_copy_file(), and unix_fcopy_file(). One works with ...
7
votes
2
answers
712
views
Wrappers around write() and read() and a function to copy file permissions
Below follows wrappers around read() and write() that retry when interrupted by a signal (the case where the return value is -1 ...
1
vote
0
answers
39
views
Determining the value of PATH_MAX on UNIX-like systems
Below is the approach taken in the function allocpath() in the book "Advanced Programming in Unix Environment", which I have modified to simply determine ...
3
votes
2
answers
104
views
Get Terminal Size, Enable and Disable Terminal Raw Mode without NCURSES
I searched around and found these 7 ways to determine the width and height of the terminal:
...
3
votes
1
answer
72
views
A quine that clones itself and runs some more quines
This is a follow-up to: A Quine program in C, where today I received the following suggestion:
Now, write the code so that the binary "clones" itself (makes a replica with an altered ...
5
votes
1
answer
547
views
A Quine program in C
From Wikipedia:
A quine is a computer program that takes no input and produces a copy of its own source code as its only output. The standard terms for these programs in the computability theory and ...
1
vote
0
answers
55
views
General Purpose Utility Constants, Macros, and Functions
Overview:
I have bundled together different macros and functions I often require in different projects into a single compilation unit (utils.h and ...
4
votes
3
answers
162
views
Type Traits for C with _Generic
Motivation:
Type traits are useful in defining robust function-like macros. Code below has:
IS_COMPATIBLE(EXPR, T)
IS_NULLPTR(T)...
6
votes
3
answers
164
views
An Attempt at Creating a Type-Safe, Generic Swap Macro With Compile Time Error Checking
Properties:
It evaluates each of A and B only once (sizeof is special, as it doesn't ...
0
votes
0
answers
18
views
Stub-Based Unit Testing 5 Read Routines (revision)
This is a follow up to: Stub-Based Unit Testing 5 Read Routines.
What's Changed:
OP's goal of reducing the source files' count has been achieved. There is now a single test source instead of 18 ...
4
votes
3
answers
141
views
Stub-Based Unit Testing 5 Read Routines
Requirements:
Following are the functions I need to test, along with the cases where they can fail:
...
9
votes
4
answers
931
views
An Attempt at Creating Generic Min()/Max() for Fundamental Types
The simplest way one can achieve this is to have separate functions for each type with a suffix to differentiate between them like the following:
...
3
votes
2
answers
69
views
Reading a file into lines (benchmarking getline() vs mmap_memchr() vs mmap_getline() vs fread())
This is a follow-up to: Reading a file into lines with mmap vs getline.
The actual names of the functions are not ...
3
votes
3
answers
340
views
Append Buffer for Buffering Small write(2) Calls
The purpose of this is written in the comment below (it is meant to be used in a text editor):
abuf.h:
...
1
vote
0
answers
45
views
Emulating C23's QChar * behavior for basename and strchrnul
To quote @Lundin from What is C23 and why should I care?:
Bug fixes for a lot of library functions (search functions in particular): we can now pass a const-qualified pointer parameter to a library ...