Skip to main content

Questions tagged [c-preprocessor]

Filter by
Sorted by
Tagged with
5 votes
3 answers
433 views

In this code I implemented arrays that store their own size before the first element. To access it you need to go back exactly sizeof(size_t) bytes back. To free it,...
yurich's user avatar
  • 157
1 vote
0 answers
71 views

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 ...
Madagascar's user avatar
  • 10.1k
4 votes
1 answer
418 views

The requirement is to define a macro which takes a single argument that is a string literal. My first try at it was to surround it with empty string literals (I got this from Modern C): ...
Madagascar's user avatar
  • 10.1k
7 votes
2 answers
828 views

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 ...
Madagascar's user avatar
  • 10.1k
2 votes
0 answers
102 views

First my apologies. My mental faculties currently leave rather a lot to be desired and I have thus spend an inordinate amount of time on this pet project of mine, testing myself if you will. I find it ...
Zacariaz's user avatar
  • 383
5 votes
1 answer
137 views

Disclaimer: I've asked this question before on Stack overflow and got a response that this place would be a better fit so I am copy pasting the question here. I've come up with two different ...
user1806687's user avatar
12 votes
4 answers
3k views

I wrote a generic dynamic array using the preprocessor. My use case for it is a compiler I'm writing that uses dynamic arrays a lot, and my current void pointer implementation is becoming a bit hard ...
Itai Nelken's user avatar
5 votes
1 answer
334 views

I have wrote a smart string container implementation for use in my application, but as I'am not such professional C programmer I have doubts about is I'am did it right and is there ways how to improve ...
Alex's user avatar
  • 53
3 votes
0 answers
103 views

I'm a computer science student, and in 2 of my courses this semester we are writing short C programs to demonstrate the things we are learning about. All of these programs require command-line flags &...
Jake Grossman's user avatar
1 vote
1 answer
130 views

I'm writing some code to take high precision timings of a function call ...
Jay's user avatar
  • 212
4 votes
1 answer
1k views

We all know the classic version of counting the number of elements in a C array: sizeof(a)/sizeof(*a) But this is dangerous, because if used on a pointer it will ...
klutt's user avatar
  • 913