Skip to main content
15 votes
3 answers
411 views

Often, I'd like to chain preprocessor conditionals involving __has_include (defined in C++17 and C23, and supported in earlier versions as an extension by many compilers (GCC 4.9.2 and up, and Clang ...
Noam Elul's user avatar
  • 854
0 votes
1 answer
129 views

I want to remove the comma characters inside __VA_ARGS__. I have found a FOR_EACH implementation, which kind of solves it, but gives cluttered error messages when there is a mistake. My problem has ...
clash's user avatar
  • 101
Advice
0 votes
6 replies
232 views

I need to layout a structure in two different ways depending on the endianness of the target platform. Currently I'm using an additional pre-compile phase to run a program to test the endianness, and ...
Alnitak's user avatar
  • 341k
-4 votes
1 answer
93 views

I'm experimenting a bit with trying to build NodeJS 24.11.1 with GCC 13.4.0 on an older OS X system, mostly as a can-it-be-done project. Regardless of the reasons, among the hurdles that could be ...
RJVB's user avatar
  • 820
5 votes
1 answer
173 views

The same code, one generated by macros and the other handwritten, produces different results.I'm lost and don't know how to fix it. my environment is follow: vs2019, msvc2019_64, c++14 if using ...
user31892351's user avatar
2 votes
1 answer
122 views

I wrote my "Result" macro header, using C23 and some of the newest features: #pragma once #include <stdio.h> #include <stdlib.h> #define __RESULT_EAT_PARENS(...) __VA_ARGS__ ...
Karesis's user avatar
  • 23
1 vote
1 answer
64 views

This snippet is mostly from the Cloak wiki, C Preprocessor tricks, tips and idioms, with DEFER2, X1, and X2 added by me for ease of referencing things in this post. #define EMPTY() #define DEFER(id) ...
Harry's user avatar
  • 4,031
8 votes
6 answers
878 views

If it's possible, I would like to define a macro that would take number of arguments in function template ARGS_COUNT and make a template with all argument types being enumerated and output being ...
kusok_kvarka's user avatar
0 votes
2 answers
111 views

I have #file debug.h #ifndef PDEBUG #define PDEBUG(msg ...)\ logger_write(logger_stdout, (struct log) {\ .level_target = LOGLEV_DEBUG,\ .message = msg,\ .properties = strdict_make_from_va(...
user973223's user avatar
3 votes
2 answers
166 views

Please consider the following minimal example: #include <stdio.h> // Compile with: // gcc -g -o myprogram main.c //#define SPECIAL typedef struct { int id; char name[50]; float value; } ...
sdbbs's user avatar
  • 5,994
-3 votes
1 answer
141 views

#include <stdio.h> #define n 16 #define a -2.0 #define b 2.0 #define c (b-a)/n int main() { printf("%lf\n",5.0*c); } Outputs 1.250000 But if i change (b-a)/n to b/n-a/n it outputs ...
Peter's user avatar
  • 137
5 votes
1 answer
139 views

Lets say I have some manner of type safety macro based on _Generic, which I use to wrap an actual function call to make it type safe: #include <stdio.h> void print (int i) { printf("%d\n&...
Lundin's user avatar
  • 220k
1 vote
1 answer
189 views

Im trying to build old version of openwrt and Im getting this error #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then ...
Vido's user avatar
  • 242
4 votes
1 answer
184 views

Problem Description C++17 introduced the __has_include preprocessor expression, which has the following two forms: __has_include(header-name) __has_include(header-name-tokens) For the first form, ...
Pluto's user avatar
  • 1,124
0 votes
1 answer
112 views

This does not answer my need. I do not want to generate an error, I want to adapt the behavior of the software depending on the condition. Example: #if ( sizeof(unsigned long) == 4 ) # define a 5 #...
virolino's user avatar
  • 2,331

15 30 50 per page
1
2 3 4 5
398