this post was submitted on 24 Feb 2024
13 points (76.0% liked)
Programming
17270 readers
39 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Languages like C have a preprocessor. The preprocessor preprocesses the source code before compiling it. The C preprocessor, copy-pastes code from other files into the current file (
#include
s), erases code (#if
if the condition is false), and expands macros (e.g. you have#define MAX(x, y) ((x) < (y) ? (y) : (x))
, it replaces every use of that macro with the definition of that macro:a += a * MAX(b, c)
โa += a * ((b) < (c) ? (c) : (b))
. There are also general-purpose preprocessors (or macro processors), that are not tied to a specific programming language however. m4 is one of them and GNU autotools make extensive use of them to generate their configuration and make files. What preprocessors allow one to do is write a template, and then generate a result, based on your needs.