Another fancy word! During a region discussion earlier this year I came across something that looked like regions, preprocessor directives. Wow. Fancy words. Let’s try that again Pre-Processor-Directives. What is that? Well, regions are preprocessor directives if I’ve understood MSDN correctly, but they don’t do much – it’s more of an editor feature that sure sparked some debate on my blog a few days ago (37 comments so far :D!! ).
So what are preprocessor directives? I had to look this up, as I wasn’t quite sure, not 100%. (And please forgive my VERY simplified and short answer, it’s late, I’ve been working for 14 h non-stop and I am dead tired. I’ll work a bit more on this blog post later this week)
SO you have your code, the source code. When you compile and run that code you get your program (hopefully) up and running. So it’s the puzzle that pieces together your program. If you would like to treat some pieces of that puzzle differently by the compilator you can use preprocessor directives to tell the compiler how to treat that part of the code. For example, you might want to skip something during debug and debug only etc. Basically you have these ones to work with:
Example from MSDN:
Pretty neat stuff I reckon! Have you used preprocessor directives? And what would be some great usage scenarios? I know my answer is very simplified, I tried to come up with a great explanation for how it works behind the scenes, but I got a tiny bit confused – and then I ran out of time and had to go to bed 🙂 Would love some more info about that, so please share if you have some great links!