{"id":14015,"date":"2023-02-22T14:26:06","date_gmt":"2023-02-22T08:56:06","guid":{"rendered":"https:\/\/fastbitlab.com\/?p=14015"},"modified":"2023-09-16T14:42:27","modified_gmt":"2023-09-16T09:12:27","slug":"microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 181| Pre-Processor directives in &#8216;C&#8217;"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 40px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<div class=\"boldgrid-shortcode\" data-imhwpb-draggable=\"true\">\n\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"font-size: 30px; border-width: 0px; line-height: 50px; font-family: 'Roboto Slab'; font-weight: 400; margin-top: 10px; text-align: center;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Pre-Processor directives in &#8216;C&#8217;<\/span><\/strong><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"border-width: 0px; font-size: 25px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><strong><span style=\"text-decoration: underline;\">Pre-Processor directives<\/span><\/strong><\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">In C programming pre-processor directives are used to affect compile time settings of the program.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Pre-processor directives are also used to create macros used as a textual replacement for numbers and other things.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Pre-processor directives begin with the<strong> \u2018#\u2019<\/strong> symbol.<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"padding-left: 40px; border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">For example, #include, #define, #if, #else if like that. So, those are different types of pre-processor directives supported by the &#8216;C&#8217; programming language.<\/span><\/p>\n<p class=\"\" style=\"padding-left: 40px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, in all your program you used these pre-processor directives, at least you used #include. So, #include is one type of pre-processor directive, which instructs the compiler to do the file inclusion.&nbsp;<\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Pre-processor directives are resolved or taken care during the pre-processing stage of compilation.<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And pre-processor directives direct the compiler to take certain actions during compile time.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 20px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><strong><span style=\"text-decoration: underline;\">Pre-processor directives supported in &#8216;C&#8217; programming language<\/span><\/strong><\/span><\/p>\n<figure id=\"attachment_14018\" aria-describedby=\"caption-attachment-14018\" style=\"width: 534px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-14018 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-1-10.png\" alt=\"Figure 1. Pre-processor directives supported in 'C'\" width=\"534\" height=\"244\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10.png 1713w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10-300x137.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10-1024x468.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10-768x351.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10-600x274.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10-1536x702.png 1536w\" sizes=\"(max-width: 534px) 100vw, 534px\" \/><figcaption id=\"caption-attachment-14018\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Pre-processor directives supported in &#8216;C&#8217;<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">We most commonly use pre-processor directives while we write macros and when we want to do file inclusion.<\/span><\/p>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #800080;\"><b>Macros<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">If you want to write macros in your program, then you have to use #define.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Macros are nothing but they are just a textual replacement for numbers and other things. #define is one type of pre-processor directive and it is used to write macros in &#8216;C&#8217;.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 18px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400; padding-left: 40px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #ff0000;\"><strong>#define Directive:<\/strong><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #800080;\"><b>File inclusion<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 18px; line-height: 30px; padding-left: 40px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #ff0000;\"><strong><span style=\"font-family: 'Roboto Slab';\">#include<\/span> <\/strong><b style=\"font-family: 'Roboto Slab'; font-weight: 400;\">Directive:<\/b><\/span><\/p>\n<ul class=\"\">\n<li style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"font-weight: 400; color: #000000;\"><strong><span style=\"color: #000080;\">#include<\/span><\/strong> is another type of pre-processor directive supported by &#8216;C&#8217;, which is used for file inclusion. A file may be a header file or any other file you can include a standard library header file or user-defined file etc.<\/span><\/li>\n<li style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"text-decoration: underline; color: #000080;\"><strong>Example:<\/strong><\/span> <code>#include &lt;stdio.h&gt;<\/code><\/li>\n<\/ul>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #800080;\"><b>Conditional compilation<\/b><\/span><\/p>\n<p class=\"\" style=\"padding-left: 40px; font-size: 18px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #ff0000;\"><strong> #ifdef, #endif, #if, #else, #ifndef, #undef&nbsp; Directives:<\/strong><\/span><\/p>\n<ul class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li><span style=\"color: #000000;\">These directives are used for conditional compilation. They allow you to include or exclude blocks of code based on whether certain macros are defined.<\/span><\/li>\n<li><span style=\"font-weight: 400; color: #000000;\">These are used to direct the compiler about code compilation.&nbsp;<\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And there are other pre-processor directives which are used for conditional compilation.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 20px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #800080;\"><b>Other<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And there are other pre-processor directives such as #pragma, #warning, #line and #error, etc.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 25px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #ff0000;\"><b>Macros in \u2018C\u2019<\/b><\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Macros are written in &#8216;C&#8217; using the<\/span><span style=\"color: #000080;\"><b> #define<\/b><\/span><span style=\"font-weight: 400;\"> pre-processor directive.<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Macros are used for textual replacement in the code, commonly used to define constants.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Syntax: <\/span><span style=\"color: #000080;\"><b>#define &lt;Identifier&gt; &lt;value&gt;<\/b><\/span><span style=\"font-weight: 400;\">&nbsp;&nbsp;<\/span><\/span><\/li>\n<\/ul>\n<p class=\"\" style=\"padding-left: 40px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">please note that there is a space between the pre-processor directive and the identifier and there is a space between the identifier and a value.<\/span><\/p>\n<ul class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Example: <\/span><span style=\"color: #000080;\"><b>#define MAX_RECORD 10<\/b><\/span><\/span><\/li>\n<\/ul>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let&#8217;s consider one simple use case.<\/span><\/p>\n<figure id=\"attachment_14019\" aria-describedby=\"caption-attachment-14019\" style=\"width: 515px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-14019 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-2-8.png\" alt=\"Figure 2. Use case\" width=\"515\" height=\"262\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-2-8.png 1903w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-2-8-300x153.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-2-8-1024x521.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-2-8-768x391.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-2-8-600x306.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-2-8-1536x782.png 1536w\" sizes=\"(max-width: 515px) 100vw, 515px\" \/><figcaption id=\"caption-attachment-14019\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Use case<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">if(age&lt;18) this expression variable is compared with a constant.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">if(age&lt; MIN AGE) this expression is written here using a macro, and MIN_AGE 18 this macro is defined here #define MIN_AGE 18.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, during the pre-processing stage of the compilation, the identifier MIN_AGE will be replaced by number 18 by the pre-processing engine of the compiler.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_14020\" aria-describedby=\"caption-attachment-14020\" style=\"width: 633px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-14020 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-3-6.png\" alt=\"Figure 3. Use case\" width=\"633\" height=\"322\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-3-6.png 1663w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-3-6-300x153.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-3-6-1024x522.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-3-6-768x391.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-3-6-600x306.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-3-6-1536x782.png 1536w\" sizes=\"(max-width: 633px) 100vw, 633px\" \/><figcaption id=\"caption-attachment-14020\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Use case<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"text-decoration: underline; color: #ff0000;\"><b>Note:<\/b><\/span><b> <\/b><span style=\"font-weight: 400;\">During the pre-processing stage of the compilation process, macro names or identifiers are replaced by the associated values inside the program<\/span><span style=\"font-weight: 400;\">.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And you should also note that MIN_AGE is not a variable. This is an identifier(macro name). That is just a textual replacement for a number.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<blockquote class=\"\">\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #333399;\"><b>In Embedded system programming, we use lots of &#8216;C&#8217; macros to define pin numbers, pin values, crystal speed, peripheral register addresses, memory addresses and for various other configuration values.<\/b><\/span><\/p>\n<\/blockquote>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">These are some examples, as shown in Figure 4.<\/span><\/p>\n<figure id=\"attachment_14021\" aria-describedby=\"caption-attachment-14021\" style=\"width: 592px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14021 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-4-6.png\" alt=\"Figure 4. Examples\" width=\"592\" height=\"292\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-4-6.png 1179w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-4-6-300x148.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-4-6-1024x505.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-4-6-768x378.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-4-6-600x296.png 600w\" sizes=\"(max-width: 592px) 100vw, 592px\" \/><figcaption id=\"caption-attachment-14021\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Examples<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here macro names are written using uppercase letters. That is a convention.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">You can either use capital letters or lowercase letters, it doesn&#8217;t matter actually. But we usually use capital letters to distinguish between a variable name and a macro. Because variable names we don&#8217;t write in capital letters. So, we always use a combination of capital and small letters or something like that.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">If you use all capital letters for the macros, then you can easily distinguish between a variable and a macro name.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">And you should also note that <strong><span style=\"color: #ff6600;\">&#8220;<\/span><\/strong><\/span><span style=\"color: #ff6600;\"><b>there is no semicolon to terminate the statement&#8221;<\/b><\/span><span style=\"font-weight: 400;\">. You should not give any semicolons.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #ff0000;\"><b>Example:<\/b><\/span> <span style=\"color: #333399;\"><b>#define XTAL_SPEED 8000000UL<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, the crystal speed is 8 mega, and it is terminated with the letter UL. UL means unsigned long, so that is allowed. You can use those characters. So, with the number, tell the compiler that this number is of type unsigned long. So, the compiler considers this macro as an unsigned long value. <\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 25px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>function-like-macros<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">To define a function-like macro, use the same &#8216;<\/span><span style=\"color: #800080;\"><b>#define<\/b><\/span><span style=\"font-weight: 400;\">&#8216; directive, but put a pair of parentheses immediately after the macro name. <\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/span><\/p>\n<figure id=\"attachment_14022\" aria-describedby=\"caption-attachment-14022\" style=\"width: 526px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14022\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-5-4.png\" alt=\"Pre-Processor directives in 'C'\" width=\"526\" height=\"261\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-5-4.png 1869w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-5-4-300x149.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-5-4-1024x508.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-5-4-768x381.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-5-4-600x298.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-5-4-1536x762.png 1536w\" sizes=\"(max-width: 526px) 100vw, 526px\" \/><figcaption id=\"caption-attachment-14022\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Example<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Here <\/span><b><span style=\"color: #800080;\">#define <span style=\"color: #993366;\">PI_VALUE 3.1415<\/span><\/span><\/b><span style=\"font-weight: 400;\"> is a normal macro definition.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b><span style=\"color: #800080;\">#define<\/span> <span style=\"color: #993366;\">AREA_OF_CIRCLE(r) PI_VALUE * r * r<\/span><\/b><span style=\"font-weight: 400;\"> is a function like macro.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"color: #993366;\"><b>AREA_OF_CIRCLE(r)<\/b><\/span><span style=\"font-weight: 400;\"> is a macro name and <\/span><span style=\"color: #993366;\"><b>PI_VALUE * r * r<\/b><\/span><span style=\"font-weight: 400;\"> is a value.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here that is a function-like macro, because we have used parentheses and that is one argument &#8216;r&#8217;, and that &#8216;r&#8217; is used for the expression of the value.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The pre-processor directives in this code are #define statements.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The first statement, #define PI_VALUE 3.1415, creates a macro that substitutes the symbol &#8220;PI_VALUE&#8221; with the value 3.1415 whenever it appears in the code.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The second statement, #define AREA_OF_CIRCLE(r) PI_VALUE * <\/span><i><span style=\"font-weight: 400;\">r * <\/span><\/i><span style=\"font-weight: 400;\">r, creates a macro that calculates the area of a circle when given the radius &#8220;r&#8221;.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the original &#8220;C&#8221; statement, areaCircle is assigned the value of the macro AREA_OF_CIRCLE with the argument &#8220;radius&#8221;.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">However, the pre-processor will replace AREA_OF_CIRCLE with its definition (PI_VALUE * <\/span><i><span style=\"font-weight: 400;\">r * <\/span><\/i><span style=\"font-weight: 400;\">r) and substitute &#8220;radius&#8221; for &#8220;r&#8221;. This results in the processed statement:<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">areaCircle = PI_VALUE * <\/span><i><span style=\"font-weight: 400;\">radius * <\/span><\/i><span style=\"font-weight: 400;\">radius;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The pre-processor will then replace PI_VALUE with its value, 3.1415, leading to the final statement:<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">areaCircle = 3.1415 * <\/span><i><span style=\"font-weight: 400;\">radius * <\/span><\/i><span style=\"font-weight: 400;\">radius;<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This is very important.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"color: #993366;\"><b><span style=\"color: #800080;\">#define<\/span> AREA_OF_CIRCLE(r) PI_VALUE * r * r<\/b><\/span><span style=\"font-weight: 400;\"> this macro is poorly written and it is dangerous. You should not write a function like macro like this, as shown in Figure 6.<\/span><\/span><\/p>\n<figure id=\"attachment_14023\" aria-describedby=\"caption-attachment-14023\" style=\"width: 507px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14023\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-6-4.png\" alt=\"Pre-Processor directives in 'C'\" width=\"507\" height=\"204\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-6-4.png 1757w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-6-4-300x121.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-6-4-1024x412.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-6-4-768x309.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-6-4-600x241.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-6-4-1536x618.png 1536w\" sizes=\"(max-width: 507px) 100vw, 507px\" \/><figcaption id=\"caption-attachment-14023\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Example<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Why is that?&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">You have to be careful with macro &#8216;values\u2019 when you are doing some \u201coperations\u201d using multiple \u201coperands\u201d.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here PI_VALUE * r* r is a macro value.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Consider PI_VALUE * r* r value. This value is a combination of operators and operands. So, when the value is a combination of operands and operators you have to be careful. You should not write something like this.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let&#8217;s see why it is bad. So, we will write one small piece of code to understand why exactly this is poorly written and how it is dangerous.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Write a program to calculate the area of a circle. I create a variable float area_circle. And I&#8217;m going to use a function like macro.<\/span><\/p>\n<figure id=\"attachment_14024\" aria-describedby=\"caption-attachment-14024\" style=\"width: 608px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14024 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-7-3.png\" alt=\"Figure 7. Code \" width=\"608\" height=\"329\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-7-3.png 1333w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-7-3-300x162.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-7-3-1024x554.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-7-3-768x415.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-7-3-600x325.png 600w\" sizes=\"(max-width: 608px) 100vw, 608px\" \/><figcaption id=\"caption-attachment-14024\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Code<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The first two lines define two macros: <\/span><span style=\"color: #993366;\"><b>PI_VALUE<\/b><\/span><span style=\"font-weight: 400;\"> and <\/span><span style=\"color: #993366;\"><b>AREA_OF_CIRCLE<\/b><\/span><span style=\"font-weight: 400;\">.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b><span style=\"color: #800080;\">#define<\/span> <span style=\"color: #993366;\">PI_VALUE 3.1415f<\/span><\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This line defines the macro PI_VALUE as a float type constant with a value of 3.1415. I consider 3.1415 as a float. You can give a Capital \u2018F&#8217; or a small &#8216;f&#8217; here. It tells the compiler that this is a &#8216;float&#8217; value, otherwise, the compiler will treat this as a double.<\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b><span style=\"color: #800080;\">#define<\/span> <span style=\"color: #993366;\">AREA_OF_CIRCLE(x) PI_VALUE * x * x<\/span><\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This line defines the macro AREA_OF_CIRCLE that calculates the area of a circle based on the given radius &#8216;x&#8217;. The formula used is the value of PI_VALUE multiplied by the radius squared.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the main function:<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><b><span style=\"color: #800080;\">float<\/span> <span style=\"color: #993366;\">area_circle;<\/span><\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This line declares a variable area_circle to store the calculated area.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #993366;\"><b>area_circle = AREA_OF_CIRCLE(2);<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This line calls the macro AREA_OF_CIRCLE with a value of 2 for the radius, which calculates the area of a circle with a radius of 2 and stores the result in area_circle.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #993366;\"><b>printf(\u201cArea = %f\\n\u201d, area_circle);<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This line prints the result stored in area_circle to the console. The %f format specifier is used to print a float value.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, you got the answer 12.566. That&#8217;s correct, as shown in Figure 7.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, instead of passing 2, I pass 1 + 1. People may use your macro in various ways. So, you never know how the user is going to use your macro.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The answer changes, as shown in Figure 8. That means something is wrong with the macro.<\/span><\/p>\n<figure id=\"attachment_14025\" aria-describedby=\"caption-attachment-14025\" style=\"width: 604px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14025\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-8-2.png\" alt=\"Pre-Processor directives in 'C'\" width=\"604\" height=\"329\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-8-2.png 1321w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-8-2-300x163.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-8-2-1024x557.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-8-2-768x418.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-8-2-600x327.png 600w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><figcaption id=\"caption-attachment-14025\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. Code<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">What happens when we do this? There is a replacement. AREA_OF_CIRCLE(1+1) is replaced by PI_VALUE * x * x.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, let&#8217;s do that.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, x is replaced by 1+1, and PI_VALUE is replaced by 3.1415f. So, the final code looks something like this, as shown in Figure 9.<\/span><\/p>\n<figure id=\"attachment_14026\" aria-describedby=\"caption-attachment-14026\" style=\"width: 622px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14026\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-9-2.png\" alt=\"Pre-Processor directives in 'C'\" width=\"622\" height=\"342\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-9-2.png 1355w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-9-2-300x165.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-9-2-1024x563.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-9-2-768x422.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-9-2-600x330.png 600w\" sizes=\"(max-width: 622px) 100vw, 622px\" \/><figcaption id=\"caption-attachment-14026\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 9. Code<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here 3.1415f * 1+1 * 1+1 this expression will be evaluated according to the precedents rule. That&#8217;s why the result that you get here is an error. Area = 5.141500 is a wrong result.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, that&#8217;s what I wanted to say &#8220;Never write values like this for a macro&#8221; (Figure 6).&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">You write something like this, as shown in Figure 10. You have to use parentheses generously. So, use parentheses for every operand. <\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/span><\/p>\n<figure id=\"attachment_14027\" aria-describedby=\"caption-attachment-14027\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14027\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-10-2.png\" alt=\"Figure 10. Example\" width=\"575\" height=\"247\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-10-2.png 1729w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-10-2-300x129.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-10-2-1024x440.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-10-2-768x330.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-10-2-600x258.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-10-2-1536x660.png 1536w\" sizes=\"(max-width: 575px) 100vw, 575px\" \/><figcaption id=\"caption-attachment-14027\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 10. Example<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">T<\/span><span style=\"font-weight: 400;\">his is the correct and safest method. <\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s do that. Here I use parentheses. This is the best way to write a macro. Let&#8217;s check this. You get the correct answer, as shown in Figure 11.<\/span><\/p>\n<figure id=\"attachment_14028\" aria-describedby=\"caption-attachment-14028\" style=\"width: 561px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14028\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/02\/Figure-11-2.png\" alt=\"Pre-Processor directives in 'C'\" width=\"561\" height=\"316\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-11-2.png 1335w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-11-2-300x169.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-11-2-1024x576.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-11-2-768x432.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-11-2-600x338.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-11-2-800x450.png 800w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><figcaption id=\"caption-attachment-14028\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 11. Code<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 25px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>Best practices while writing macros in &#8216;C&#8217;<\/b><\/span><\/p>\n<ol class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Use meaningful macro names<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">It&#8217;s recommended that you use UPPER case letters for macro names to distinguish them from variables.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Remember, macro\u2019s names are not variables. They are labels or identifiers, and they don&#8217;t consume any code space or ram space during compile time or runtime of the program.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">Make sure that parentheses surround the macro value.&nbsp;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400; color: #000000;\">While using function-like macros or when you are using macros along with any operators, always surround the operands with parentheses.&nbsp;<\/span><\/li>\n<\/ol>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">In the following article, let\u2019s learn about conditional compilation using pre-processor directives.<\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 23px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; border-width: 0px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\"><span style=\"color: #000000;\">lick here:<\/span><span style=\"color: #0000ff;\">&nbsp;<\/span><\/span><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Pre-Processor directives in &#8216;C&#8217; &nbsp; Pre-Processor directives In C programming pre-processor directives are used to affect compile time settings of the program.&nbsp; Pre-processor directives are also used to create macros used as a textual replacement for numbers and other things. Pre-processor directives begin with the \u2018#\u2019 symbol. For example, #include, #define, #if, #else if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":14018,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[16],"class_list":["post-14015","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-microcontroller-embedded-c-programming","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pre-Processor directives in C | FastBit EBA<\/title>\n<meta name=\"description\" content=\"Pre-Processor directives in &#039;C&#039;. In C programming pre-processor directives are used to affect compile time settings of the program. Macros in\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pre-Processor directives in C | FastBit EBA\" \/>\n<meta property=\"og:description\" content=\"Pre-Processor directives in &#039;C&#039;. In C programming pre-processor directives are used to affect compile time settings of the program. Macros in\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-22T08:56:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-16T09:12:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1713\" \/>\n\t<meta property=\"og:image:height\" content=\"783\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 181| Pre-Processor directives in &#8216;C&#8217;\",\"datePublished\":\"2023-02-22T08:56:06+00:00\",\"dateModified\":\"2023-09-16T09:12:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/\"},\"wordCount\":1770,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/Figure-1-10.png\",\"keywords\":[\"Microcontroller Embedded C programming Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/\",\"name\":\"Pre-Processor directives in C | FastBit EBA\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/Figure-1-10.png\",\"datePublished\":\"2023-02-22T08:56:06+00:00\",\"dateModified\":\"2023-09-16T09:12:27+00:00\",\"description\":\"Pre-Processor directives in 'C'. In C programming pre-processor directives are used to affect compile time settings of the program. Macros in\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/Figure-1-10.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/Figure-1-10.png\",\"width\":1713,\"height\":783,\"caption\":\"Figure 1. Pre-processor directives supported in 'C'\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 181| Pre-Processor directives in &#8216;C&#8217;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pre-Processor directives in C | FastBit EBA","description":"Pre-Processor directives in 'C'. In C programming pre-processor directives are used to affect compile time settings of the program. Macros in","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/","og_locale":"en_US","og_type":"article","og_title":"Pre-Processor directives in C | FastBit EBA","og_description":"Pre-Processor directives in 'C'. In C programming pre-processor directives are used to affect compile time settings of the program. Macros in","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2023-02-22T08:56:06+00:00","article_modified_time":"2023-09-16T09:12:27+00:00","og_image":[{"width":1713,"height":783,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 181| Pre-Processor directives in &#8216;C&#8217;","datePublished":"2023-02-22T08:56:06+00:00","dateModified":"2023-09-16T09:12:27+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/"},"wordCount":1770,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10.png","keywords":["Microcontroller Embedded C programming Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/","name":"Pre-Processor directives in C | FastBit EBA","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10.png","datePublished":"2023-02-22T08:56:06+00:00","dateModified":"2023-09-16T09:12:27+00:00","description":"Pre-Processor directives in 'C'. In C programming pre-processor directives are used to affect compile time settings of the program. Macros in","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/02\/Figure-1-10.png","width":1713,"height":783,"caption":"Figure 1. Pre-processor directives supported in 'C'"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-181-pre-processor-directives-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 181| Pre-Processor directives in &#8216;C&#8217;"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=14015"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14015\/revisions"}],"predecessor-version":[{"id":15976,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/14015\/revisions\/15976"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/14018"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=14015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=14015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=14015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}