Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [c11]

C11 is a standard for the C programming language. It replaces the previous C99 standard. C11 added type-generic expressions, alignment support, static assertions, library support for multithreading and unicode as well as multiple other language and library fixes and additions.

Filter by
Sorted by
Tagged with
6 votes
4 answers
866 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: ...
Harith's user avatar
  • 7,334
12 votes
2 answers
1k views

Header-only log-structured database

I'm seeking a code review for the ~2000 lines of code. Makefile and tests are available at https://github.com/torrentg/logdb. I would appreciate feedback on the following aspects: Overall code ...
Gerard Torrent's user avatar
11 votes
2 answers
2k views

Brainfuck to C transpiler

I have been working on making a transpiler from Brainfuck to C in C(11), here is the code: ...
FFmpegEnthusiast's user avatar
6 votes
2 answers
151 views

Generic map-like function

This function mimics Python's map() function (No, it doesn't support generic return types for the function or multiple iterables) by applying the provided function <...
Harith's user avatar
  • 7,334
4 votes
3 answers
515 views

C11 zero copy lock-free triple buffer

The code is for a single producer, single consumer scenario, where the consumer only cares about the latest information shared by the producer. This is just a simple proof of concept created for linux....
mausys's user avatar
  • 49
3 votes
5 answers
167 views

Calculate a math sequence that converges

Thanks for taking the time to read this. I could use a few pointers. I have written much better code but wrote this as a quick test. There is obviously a major issue/s somewhere except for the ...
J123's user avatar
  • 33
-1 votes
1 answer
152 views

Brainfuck interpreter in C, looking for improvements on the looping functionality [closed]

I've just started to get into PL design and made a simple Brainfuck interpreter. Although it is functional, I don't feel too confident on the execution, particularly the implementation for loops, I ...
Iñaki Ulibarri's user avatar
2 votes
3 answers
2k views

Simplified print and input macros in C

For a program I'm writing, it requires a lot of printing and receiving user input. I've found it cumbersome to keep specifying the type strings in printf, and ...
Linny's user avatar
  • 10.1k
3 votes
0 answers
83 views

Async generation of large buffers of random numbers on the GPU

I would like to obtain some feedback on a simple code I wrote to implement an easy and hopefully fast way to generate a large number of floats with CURAND and use them one at a time. This is achieved ...
rng_help's user avatar
3 votes
1 answer
86 views

Basic Subnet Mask Calculator + A Little Extra

For my Networking class, we learned about subnetting and subnet masks. I decided to write a little "calculator" (a generous term) that when given n-many network ...
Carcigenicate's user avatar
5 votes
2 answers
1k views

Implementation of memset_s based on C11 standard

The following code attempts to implement memset_s() based on section K.3.7.4.1 of the ISO/IEC 9899:201x N1570 draft: ...
Tanveer Salim's user avatar
12 votes
1 answer
1k views

Function to print a double, in decimal - exactly

Rarely is the exact decimal value of a double needed to be printed and only its leading significant digits, after rounding, are needed. It is a curiosity to see the ...
chux - Reinstate Monica's user avatar
9 votes
5 answers
7k views

Convert UTF8 string to UTF32 string in C

I'm doing some recreational programming in C (after spending some time in C++, but professionally using only PHP/JavaScript). I wrote a UTF8 to UTF32 converter and just wanted to know if I made some ...
S22h's user avatar
  • 193
2 votes
0 answers
184 views

Lock-free statically allocated async-interrupt-safe multi-consumer double buffer

I have a single threaded embedded system with nested interrupts. A writer interrupt will periodically update some global data structure with data. Reader interrupts / calls from main thread will read ...
user80551's user avatar
  • 121
3 votes
1 answer
250 views

Stack allocator and C11's alignment features

I am trying to write a custom stack allocator for a game I am working on. To deal with memory alignment, I am using C11's stdalign.h header; however, since I do not ...
strNOcat's user avatar
  • 131
3 votes
2 answers
147 views

Simple command line option parser

As part of a project where I will be rewriting the most common GNU coreutils for practice purposes, I wrote a simple command line option parser in C. The parser works by categorizing ...
Ben Steffan's user avatar
  • 5,228
8 votes
2 answers
230 views

A dynamic string interface in C

So I've written up what the title says. Obviously, I'm looking for speed, safety and ease of use. To achieve the perfect ratio I've made some functions straight away crash if the input is wrong (in ...
DeiDei's user avatar
  • 551
4 votes
1 answer
199 views

IRC Client with TLS and SASL support

I wrote this little program to... I don't know. But it connects to IRC servers using OpenSSL and can login via SASL. The code needs refactoring, of that I'm certain, but I need some advice in that ...
Ezechiel's user avatar
  • 137
4 votes
0 answers
74 views

Fast lock implementation using pipes only

For fun I wanted to create a lock implementation that was about as fast as one using futexes but that used used pipes instead and that queues waiters in user space instead of in-kernel. For the queue ...
Ms. Molly Stewart-Gallus's user avatar
5 votes
2 answers
70 views

Calculate maximum possible helpful flags for n days

This program is supposed to calculate the mathemathical maximum of helpful flags you can have on the nth day, starting with 0 helpful flags, using the StackExchange ...
Magisch's user avatar
  • 330
4 votes
2 answers
132 views

A dynamic memory resource with alignment support

Although C11 introduced aligned_alloc( alignment, size ), there is no support for aligned reallocation (AFAIK). The ...
user2296177's user avatar
  • 3,543
3 votes
1 answer
124 views

Generic variable-size array

As stated in the tags, I'm a beginner to C. This code implements a dynamic array (List in .NET, vector in C++, etc) for any ...
Kroltan's user avatar
  • 284
7 votes
2 answers
3k views

Simple OpenGL image viewer in C

I'm making an image viewer and before I continue development I want to make sure I haven't done anything bad. In particular, I was wondering if my error handling is sane. Most of the code is OpenGL/...
Ezechiel's user avatar
  • 137
4 votes
1 answer
356 views

A Generic Approach To Doubly Linked Lists

I've written a small implementation for doubly linked lists. While actually intended to be only used by me in subsequent projects, I wrote it as generically as possible. Maybe this'll be advantageous. ...
cadaniluk's user avatar
  • 187
1 vote
4 answers
156 views

Copy/remove characters "in place" without causing UB from strcpy

I am writing a portable library function, which is a generic "remove characters" function. Language standards used are C11 and MISRA-C:2012. TL;DR: it should either remove all occurrences of a ...
Lundin's user avatar
  • 4,660
5 votes
1 answer
706 views

Dining Philosophers using C11 threads

I wanted to try multithreading out in C, so I did Dining Philosophers using C11 threads with the approach of having one of the philosophers left-handed. Any suggestions? ...
Vikaton's user avatar
  • 153
3 votes
2 answers
146 views

Single reader - multiple writer waitable lock-free unreliably ordered stack

The main body of code is located here. In the code linted_error is a platform specific type for error codes. As well, as an optimization the code can use Linux ...
Ms. Molly Stewart-Gallus's user avatar
9 votes
2 answers
125 views

A closed exception system

I am working on yet another toy project that I named SGL (for "Standard Generic Library" since it mimics some features of C++'s STL as well as a few more utilities from the C++ standard library). ...
Morwenn's user avatar
  • 20k
9 votes
2 answers
267 views

Reasonable way to implement "safe" math operations using _Generic?

I've been thinking about a way to make it easier to safely use math operations with C's basic datatypes (e.g. using the CERT C coding standard). So far, I've come up with something like this: ...
acarlow's user avatar
  • 193
17 votes
2 answers
5k views

Template vector struct in C11

This one review will be a little bit tricky: I was trying to implement a template Vector struct in C11. Of course, templates don't really exist in C11, so I used a ...
Morwenn's user avatar
  • 20k