is a qute dog
#define

5/n
A semantic quirk of the open() uapi is the definition of the O_RDONLY
flag. It would seem natural to define:

#define O_RDWR (O_RDONLY | O_WRONLY)

but that isn't possible because:

#define O_RDONLY 0

This makes O_RDONLY effectively meaningless when passed to the kernel.
In other words, there has never been a way - until O_PATH at least - to
open a file without any permission; O_RDONLY was always implied on the
uapi side.

#linux

I couldn't help myself and last night started attacking unzip with @fanf 's excellent unifdef tool to see what could be done.

github.com/fragglet/antizip/co

It's like pulling weeds: you pull out one #define and then you find there are more. And more and more and more and more.

apparently #gcc can handle preprocessor directives inside a variadic argument to another macro, whereas #msvc can't, even in the "standards-compliant c++20 mode".

#define MACRO(a, ...) fprintf(a, "Hello " __VA_ARGS__ "\n")

MACRO(stdout,
#ifdef A
"World A!"
#else
"World not A!"
#endif
);

@asie oh, so they could

#define WF_CUSTOM_SCREEN
#include "wf-project.h"

to tell it that they want to define their own screen?

@wolf480pl@mstdn.io my main concern is being able to write rules in a way which allows the user to progressively "opt out" from magic depending on their skillset/needs.

how? -> for example:
#ifdef WF_MODEL_SOMETHING \ #define SCREEN_1 ((volatile uint16_t*) 0x2000) \ ... \ #endif - another option could be generating a per-project .h file containing this information

i don't want users to write .ld files directly, as the toolchain's means of layouting sections and converting ELFs to binary files is a moving target

find the bug

#define REVEAL_PASSWORD(password) \
printf("the password is:\n"); \
printf("%s\n", password);

if (password == "my_password")
REVEAL_PASSWORD(password)
else
printf("incorrect password!\n");

excerpt from some bad code
acceptable: #define gcLockName "gc.lock"
proper: constexpr char gcLockName[] = "gc.lock";
groovy: using str = char[]; constexpr str gcLockName = "gc.lock";
totally fricken wack: static std::string gcLockName = "gc.lock";

@pounce
#define BITS_PER_BYTE 8
#define BYTES_PER_CHAR 1
#define BYTES_PER_SHORT 2
#define BYTES_PER_INT FUCK_YOU

symptom: TX DAC clock rate is half what it should be

"oh this should be easy"

*hours of troubleshooting with JTAG, gdb, oscilloscopes, spectrum analyzers, etc*

actual problem: missing #define led the function that validates FIR filter configuration to use a broken memcpy implementation

Yeah it's nonstandard but it's so widely supported and is so much nicer than #ifndef BLAH_H #define BLAH_H that I feel compelled to use it

@ddipaola just sneak a `#define static` in there somewhere and now there are no private members

(hope you weren't doing anything else with that keyword)

@caurinus the cpe357 course at Cal Poly almost did this - any number other than -1, 0, 1, or 2 gave you a ten token penalty unless placed in a #define (where a token = a variable name, operator, equals sign, etc)

@revenant :chao:​:oh_no_bubble:​

or the classic "#define struct union" / "#define if while"

@falkreon i'm a fan of

void *_malloc(size_t size) {
static void *p = 0;
return (p = realloc(p, size));
}
#define malloc _malloc

@revenant
did someone say software chaos magic?

#ifdef NULL
#undef NULL
#endif
#define NULL (void*)((size_t)!rand())