1. 33
  1. 5

    Ooh, interesting. I program in C fairly regularly, and I didn’t know about macro calls in #include statements

    This is valid preprocessor:

    #define ARCH x86
    #define ARCH_SPECIFIC(file) <ARCH/file>
    #include ARCH_SPECIFIC(test.h)
    

    I like it

    1. 5

      Whenever I’ve done any hobbyist kernel devel, I’ve preferred to have something like an include/x86_64/arch folder and and include/arm/arch folder. Then I’d have, in the Makefile, cc -I include/${ARCH}, and in *.c:

      #include <arch/whatever.h>
      

      IMO it’s cleaner than symlinks (which I’ve seen in certain projects), and less likely to confuse than

      #include ARCH_SPECIFIC(whatever.h)
      
    2. 1

      Very fun! Some are even useful.

      Stories with similar links:

      1. Some obscure C features via raymii 5 months ago | 28 points | 11 comments