StartupHakk.com/?v=a4GVGVGo9nA
#coding #codingbootcamp #softwaredeveloper #CodeYourFuture
GitHub Repo: github.com/slthomason/StartupHakkSamples/tree/main…
It seems pretty obvious that you should be using the exact same code at every step of the release, though. So your code needs to be able to handle those different environments. At the same time, it would be nice if it wasn’t a headache to insure this env-compatibility; ideally, we’d like the various env settings to be readable and easily changeable.
There are plenty of ways to take this environment into account in your code. But in C#, there’s something really cool for env-dependent compilation: the preprocessor directives.
A little detour: what are C macros?
If you’ve ever done some C or C++, you’re probably familiar with macros. Those are all these weird lines that you start with a sharp sign # (and don't end with a semicolon ;!) and that let you define "variables that aren't really variables".
What do I mean by that?
Well, the real trick of C macros is that they are not read by the compiler but by the preprocessor. This particular tool runs just before the compiler: it transforms your C code into another piece of C code (still human-readable) that is very close to the original one but where all the macros have been interpreted.
The well-known #include statement is, itself, a preprocessor directive! It simply tells the preprocessor to: "go and fetch the code from this header file, and paste it here in place of the macro".
Note: this is why, in C++, you have the #pragma once statement (yet another macro!): it's a safeguard to prevent the preprocessor from re-importing a header file if it has already been copied into your preprocessed code. Otherwise, you could end up with dozens of copies of your stdio lib...! ;)
Lots of Great How Tos and Code Samples! Make sure to like and subscribe!
コメント