Questions tagged [gcc]
For code written to be compiled specifically by the GCC, which stands for the GNU Compiler Collection. Developers often compile several languages using this compiler collection.
27 questions
7
votes
6
answers
789
views
Computing the smallest number of the form floor(8^N / 7) that is greater or equal to a number
Is there a more direct way (loop-free) to compute this number than computing a level and then going back?
...
7
votes
2
answers
935
views
Integer to string converter - gcc builtins only
This is version 2 of prior post - per : CRSE:tour and Guide.
Due to unintended generalization of prior question for brevity sake, here are requirements:
Code should be portable and run on ...
7
votes
5
answers
2k
views
int128 handling in c-code, gcc / glibc / linux
[edit] Hint: a similar project for C++20 which - as far as I see - also manages bigger than 128-bit integers can be found at: Infinite precision integer in C++20 . [/edit]
I work on some performance ...
7
votes
1
answer
560
views
Integer to string via gcc converter
I've been playing with shared libraries and core functionalities with gcc/g++. Using only gcc builtins I've tried to make an integer to string converter.
...
7
votes
2
answers
828
views
Consolidating GNU C's and C23's attributes
C23 has introduced attribute specifier sequences. Consequently, the header below attempts to conditionally define macros for these sequences (for my own use cases). In cases where a compiler does not ...
8
votes
3
answers
702
views
4 different implementations of modulo with fully defined behavior
I've implemented the 3 variants of the modulo operation described on this Wikipedia page.
The goal is to have fully defined behavior for all inputs.
Code
Implementation with truncated division (result ...
6
votes
2
answers
6k
views
128-bit integer type in GCC/Clang
When working on my projects, I often need a 128-bit integer type. For this purpose, I use the __int128 compiler extension. Here is the implementation I am currently ...
7
votes
4
answers
1k
views
Encapsulating snprintf to avoid repetition of sizeof
Correct usage of snprintf involves very long and repetitive lines:
...
1
vote
4
answers
263
views
Safer & simpler allocation functions and macros
I wrote a bunch of functions and macros for safer and simpler allocation. They are documented in their files.
Disclaimer:
The library requires POSIX extensions, GCC extensions, and LIBBSD extensions,...
10
votes
3
answers
6k
views
C++ Template to implement the Factory Pattern
Design
A template class that will create a concrete instance of an interface class when given the name (as a string) of the concrete class.
This design is often seen in code, so the purpose of this ...
11
votes
3
answers
2k
views
Register "%b" conversion specifier
I'm writing a library to register the b, B conversion specifiers and make them work the closest possible to ...
4
votes
1
answer
204
views
32x32x32 units octree, that supports 15-bit data units
The idea is to have an octree that stores a 32x32x32 region of 15 bit values more efficiently than a 32x32x32 array, because if all 8 leaf nodes of a given branch are the same, the branch does not ...
3
votes
2
answers
363
views
Reference-counted smart pointer in C
About
I've been experimenting with gcc's __cleanup__ attribute, and thought it'd be a great fit for a memory-safe smart pointer for C.
This is the implementation. ...
3
votes
3
answers
1k
views
Efficiently read a file into a (C) string using POSIX APIs
Exactly what the title says, this is a C++ class that attempts to read a file into a null-terminated string as efficiently as possible, using POSIX APIs. Obviously this is not intended to be portable ...
3
votes
0
answers
721
views
Generic Makefile for C projects
I'm trying to create a generic Makefile that will work with the following directory structure:
Project Directory
Makefile
main.c source file
source directory
Source files
include directory
Header ...