Re:Learning that you can use unions in C for grouping things...
by zerr on Monday August 02, 2021 @03:46AM
(#28033948)
Making it clear in the code itself that something is platform specific is useful as well. Also, I'd say such stubs and extra files would clutter the project.
[ Parent
| on HN ]
Re:Learning that you can use unions in C for grouping things...
by WalterBright on Monday August 02, 2021 @04:58AM
(#28034401)
I tried it your way for years. It's common practice in the industry. I have written and seen plenty of rats' nests of #if and #ifdef snarls so bad one cannot figure out what is being compiled and what isn't without running a just-the-preprocessor pass. It will often #if on the wrong condition, like operating system when it's a CPU dependency.
Rewriting it the way I suggest tends to force a cleanup of all that. You'll like the results.
BTW, if you want to try transitioning to the next level, try getting rid of all the `if` statements, too!