{"id":81477,"date":"2021-07-06T09:00:57","date_gmt":"2021-07-06T03:30:57","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=81477"},"modified":"2021-07-06T09:00:57","modified_gmt":"2021-07-06T03:30:57","slug":"preprocessors-in-c","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/","title":{"rendered":"Preprocessors in C"},"content":{"rendered":"<p>In C, preprocessors are one of the most important and useful concepts. Preprocessor allows you to define macros that transform your program before it is compiled. C preprocessor is also known as CPP.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/working-of-preprocessors-in-c.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-81690\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/06\/working-of-preprocessors-in-c.jpg\" alt=\"working of preprocessors in c\" width=\"964\" height=\"533\" \/><\/a><\/p>\n<h3>What are preprocessor in C?<\/h3>\n<p>C preprocessors tell the compiler to do the required processing before its compilation. From the word \u2018preprocessor\u2019, you already know the meaning of it. \u2018Pre\u2019 means <strong>before<\/strong> and \u2018processor\u2019 means <strong>making something<\/strong>. It is not part of the compiler but it is considered as a separate step in the compilation process.<\/p>\n<p>Suppose, we have a c file named main.c with extension of .c. Preprocessors then process this file and in the next step, it gets compiled and it produces an object file with extension of .obj. After that the <strong>.obj<\/strong> file is linked with standard library functions to generate a file with extension of <strong>.exe<\/strong> and then it executes.<\/p>\n<h3>What are C Preprocessor directives?<\/h3>\n<p>It tells the compiler to preprocess the source code before compiling. Preprocessor Directives mainly used as commands. In C, all the preprocessor directives start with a <strong>hash\/pound(#)<\/strong> symbol. You can use preprocessor directives anywhere in the program. But it is best to use the preprocessor directives at the beginning of the program.<\/p>\n<p><strong>Example:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#define PI 3.14<\/pre>\n<h3>Types of Preprocessor in C<\/h3>\n<p>There are 4 main types of preprocessor directives:-<\/p>\n<ul>\n<li>Macros<\/li>\n<li>File Inclusion<\/li>\n<li>Conditional Compilation<\/li>\n<li>Other directives<\/li>\n<\/ul>\n<h3>1. Macros in C<\/h3>\n<p>Programmers use macros to execute pieces of code inside the macro. A programmer gives a name to the macro. And when the given name is encountered by the compiler then the compiler replaces the name with the piece of code which is inside the macro. The <strong>#define<\/strong> directive is used to define a macro.<\/p>\n<p><strong>Example of C Macros<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n#define LIMIT 4 \/\/ defining macro!\nint main()\n{\nfor (int a = 0; a &lt; LIMIT; a++) {\nprintf(\"%d \\n\",a);\n}\nreturn 0;\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">0<br \/>\n1<br \/>\n2<br \/>\n3<\/div>\n<p>In the above example, the compiler replaces LIMIT with 5. <strong>LIMIT<\/strong> is a macro template and<strong> 5<\/strong>\u00a0 is macro expansion.<\/p>\n<h4>Macros with arguments<\/h4>\n<p>We can also pass arguments to the macros. Macros with arguments work similarly as functions.<\/p>\n<p><strong>Example of Macros with arguments:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n#define AREA(s) (s * s) \/\/ macro with argument\nint main()\n{\nint s1 = 10, area_of_square;\narea_of_square = AREA(s1);\nprintf(\"TechVidvan Tutorial: Macros with arguments!\\n\");\nprintf(\"Area of square is: %d\", area_of_square);\nreturn 0;\n}<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">TechVidvan Tutorial: Macros with arguments!<br \/>\nArea of square is: 100<\/div>\n<p>In the above example, the compiler finds the name of the macro <strong>(AREA(s))<\/strong> and replaces it with the statement <strong>(s * s)<\/strong>.<\/p>\n<h4>Function like Macros in C<\/h4>\n<p>Define macros that work similarly like functions.<\/p>\n<p><strong>Example of Function like Macros in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n\n#define MIN(a,c) ((a) &gt; (c) ? (c) : (a))\n\nint main(void) {\n   printf(\"Between 30 and 70, minimum number is: %d\\n\", MIN(10, 20));  \n   return 0;\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">Between 30 and 70, minimum number is: 10<\/div>\n<h3>2. File Inclusion<\/h3>\n<p>This preprocessor directive tells the compiler to include a file in the program code. A user can include two types of file:-<\/p>\n<h4>a. Header or Standard files<\/h4>\n<p>These files contain functions like printf(), scanf(). In a single word, it contains predefined functions. Different header files contain different functions. Like, <strong>string<\/strong> file contains string handling functions and <strong>iostream<\/strong> file contains input\/output functions.<\/p>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;name_of_the_file&gt;<\/pre>\n<h4>b. user defined files<\/h4>\n<p>A programmer can define his\/her own header file to divide a complex code into small blocks of code.<\/p>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include\"filename\"<\/pre>\n<h3>3. Conditional Compilation in C<\/h3>\n<p>The main purpose of this preprocessor directive is to compile specific parts of the code or skip the compilation of specific parts of the code based upon some conditions.<\/p>\n<h4>How to use conditional compilation directives?<\/h4>\n<p>With the help of two preprocessing methods, you can implement the conditional compilation directive.<\/p>\n<ul>\n<li><strong>ifdef<\/strong><\/li>\n<li><strong>endif<\/strong><\/li>\n<\/ul>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#ifdef macro_name\n    statement1;\n    statement2;\n    statement3;\n    .\n    .\n    .\n    statementN;\n#endif\n<\/pre>\n<p>If the macro name is defined, then it will normally execute the block of statements. And if it is not defined, then the compiler will skip the block of statements.<\/p>\n<p>Apart from <strong>#ifdef<\/strong> and <strong>#endif<\/strong> directives, there are some other directives such as <strong>#if, #elif, #else<\/strong> and <strong>#defined<\/strong> directives.<\/p>\n<h4>#if, #elif, #else directive in C<\/h4>\n<p>You can also use <strong>#else<\/strong> directive with <strong>#if<\/strong> directive. If the given expression results in a non zero value, then the codes of conditional are included in the program.<\/p>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#if expression\n\/\/ conditional statements if expression is not zero\n#else\n\/\/ conditional statements if expression is zero\n#endif\n<\/pre>\n<p>You can also use nested conditional in your program with the help of <strong>#elif<\/strong> directive.<\/p>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#if expression1\n\/\/ conditional statements if expression1 is not zero\n#elif expression2\n\/\/ conditional statements if expression1 is not zero\n#else\n\/\/ conditional statements if all expressions is zero\n#endif\n<\/pre>\n<h4>#defined directive in C<\/h4>\n<p>Mainly used to check whether a certain macro is defined or not. You can use <strong>#if<\/strong> directive with <strong>#defined<\/strong> directive.<\/p>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#if defined LENGTH || WIDTH &gt;= 10\n  \/\/ body contains code\n<\/pre>\n<h4>Uses of C Conditional Compilation:-<\/h4>\n<ul>\n<li>Compile the same source file in different programs.<\/li>\n<li>Depending on the OS, you can use different code.<\/li>\n<\/ul>\n<h3>4. Other directives in C<\/h3>\n<p>There are also two not so used directives available in C.<\/p>\n<p><strong>a. #undef directive:-<\/strong> Mainly used to undefine an existing macro.<\/p>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#undef LIMIT<\/pre>\n<p>If you use the above statement then it will undefine the existing macro LIMIT.<\/p>\n<p><strong>b. #pragma directive:-<\/strong> Mainly used to enable or disable certain features. It varies from compiler to compiler. Below is some of the pragma directives:-<\/p>\n<ul>\n<li><strong>#pragma startup and #pragma exit:<\/strong>&#8211; Mainly used to specify the functions which are needed to run before program startup and before program exit.<\/li>\n<\/ul>\n<p><strong>Example:- pragma startup and pragma exit<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nvoid f1();\nvoid f2();\n#pragma startup f1\n#pragma exit f2\nvoid f1()\n{\n  printf(\"Executing f1() function!\\n\");\n}\n \nvoid f2()\n{\n  printf(\"Executing f2() function!\\n\");\n}\n \nint main()\n{\n  void f1();\n  void f2();\n  printf(\"TechVidvan Tutorial: pragma startup and pragma exit!\\n\\n\");\n  printf(\"Executing main() function!\\n\");\n \n  return 0;\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: pragma startup and pragma exit!<\/p>\n<p>Executing f1() function!<br \/>\nExecuting main function!<br \/>\nExecuting f2() function!<\/p>\n<\/div>\n<p>But if you run this in GCC compiler, it will give output like this:-<\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: pragma startup and pragma exit!<\/p>\n<p>Executing main function!<\/p>\n<\/div>\n<p>Because GCC compiler does not support #pragma startup or #pragma exit.<\/p>\n<ul>\n<li><strong>#pragma warn directive:-<\/strong> Mainly used to hide warning messages that are displayed while compilation.<\/li>\n<li><strong>#pragma warn -rvl:-<\/strong> Mainly used to hide the warnings when a function does not return a value as it is supposed to.<\/li>\n<li><strong>#pragma warn -par:-<\/strong> Mainly used to hide the warnings when a function does not use the parameters which are passed to it.<\/li>\n<li><strong>#pragma warn -rch:-<\/strong> Mainly used to hide the warnings when a code is unreachable.<\/li>\n<\/ul>\n<h4>C Preprocessor Examples:-<\/h4>\n<p>Below are some examples of preprocessors:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#define SIZE 42<\/pre>\n<p>In the above example, the compiler will automatically replace the macro name SIZE with 42.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;string.h&gt;\n#include \"header.h\"\n<\/pre>\n<p>In the above example, we added the <strong>string.h<\/strong> header file to make use of string handling functions. And also, we added our own header.h file from the local directory.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#undef TEST<\/pre>\n<p>It tells the compiler to undefine existing <strong>TEST.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#ifndef MOTD\n   #define MOTD \"TechVidvan Tutorial: P\"\n#endif\nIn the above example\n<\/pre>\n<p>In the above example, we have defined <strong>MOTD<\/strong> only if <strong>MOTD<\/strong> is not defined already. <strong>MOTD<\/strong> means message of the day.<\/p>\n<h3>How does a preprocessor work in C?<\/h3>\n<p>Below are the steps involved while preprocessing:-<\/p>\n<p><strong>1. Filtering out comments:<\/strong>&#8211; In C, comments are used for better understanding of different steps which are included in the program. Compiler filters out the comments during processing.<\/p>\n<p><strong>2. File Inclusion:<\/strong>&#8211; It tells the compiler to include certain header files so that certain functions can be performed. In 2 ways, you can do it:-<\/p>\n<ul>\n<li>#include&lt;filename.h&gt;<\/li>\n<li>#include\u201dfilename.h\u201d<\/li>\n<\/ul>\n<p><strong>3. Macro Expansion:<\/strong>&#8211; In some situations, you will need to use some blocks of code in a recursive function. In 2 ways, you can do it:-<\/p>\n<p><strong>4. Object-like macros:<\/strong>&#8211; Does not take parameters.<\/p>\n<p><strong>5. Function-like macros:<\/strong>&#8211; Capable of taking parameters.<\/p>\n<p><strong>Example of Object-like Macros<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n#define SIDE 4\nint main() {\n  int area;\n  area = SIDE*SIDE;\n  printf(\"TechVidvan Tutorial: Object Like Macros!\\n\");\n  printf(\"Area is: %d\",area);\n  return 0;\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">TechVidvan Tutorial: Object Like Macros!<br \/>\nArea is: 16<\/div>\n<p>In the above example, <strong>SIDE<\/strong> is the macro name and it will be replaced by value <strong>4<\/strong>.<\/p>\n<p><strong>Below is a table of preprocessor in C:-<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Preprocessor<\/b><\/td>\n<td><b>What it does<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#include<\/span><\/td>\n<td><span style=\"font-weight: 400\">To insert a specific header from a file.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#define<\/span><\/td>\n<td><span style=\"font-weight: 400\">Mainly used as a replacement of a preprocessor macro.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#ifdef<\/span><\/td>\n<td><span style=\"font-weight: 400\">If the macro is defined, it returns true. And if not, then false.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#endif<\/span><\/td>\n<td><span style=\"font-weight: 400\">Mainly used to close the preprocessor directive.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#undef<\/span><\/td>\n<td><span style=\"font-weight: 400\">To undefine a standard or user-defined header.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#pragma<\/span><\/td>\n<td><span style=\"font-weight: 400\">To enable and disable certain features.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#ifndef<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns true when micro is not defined.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#if<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks if the condition is true at compile time.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#else<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks the next condition if #if proves to be false in compile time.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#elif<\/span><\/td>\n<td><span style=\"font-weight: 400\">Used as a combination of #else and #if.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">#error<\/span><\/td>\n<td><span style=\"font-weight: 400\">Mainly used to print errors on stderr.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><strong>Predefined Macros in C<\/strong><\/h4>\n<p>One should not modify the predefined macros. Below are some predefined macros.<\/p>\n<table style=\"height: 350px\" width=\"526\">\n<tbody>\n<tr>\n<td><b>MACRO\u00a0<\/b><\/td>\n<td><b>What it does<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">__DATE__<\/span><\/td>\n<td><span style=\"font-weight: 400\">Current date as MMM DD YYYY format.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">__TIME__<\/span><\/td>\n<td><span style=\"font-weight: 400\">Current time as HH:MM:SS format.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">__FILE__<\/span><\/td>\n<td><span style=\"font-weight: 400\">Contains current filename.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">__LINE__\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">Contains current line number.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">__STDC__<\/span><\/td>\n<td><span style=\"font-weight: 400\">Defined as 1 when the compiler compiles.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Example of C Predefined Macros<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint main() {\nprintf(\"TechVidvan Tutorial: Predefined Macros!\\n\\n\");\nchar filename[] = __FILE__;\nchar date[] = __DATE__;\nchar time[] = __TIME__;\nint line = __LINE__;\nint ansi = __STDC__;\nprintf(\"File name is: %s\\n\", filename);\nprintf(\"Date is: %s\\n\", date);\nprintf(\"Now time is: %s\\n\", time);\nprintf(\"Current line number: %d\\n\", line);\nprintf(\"Compilation Success: %d\\n\", ansi);\n}\n<\/pre>\n<p>The above code is saved in a file named <strong>HelloWorld.c.<\/strong><\/p>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Predefined Macros!<\/p>\n<p>File name is: main.c<br \/>\nDate is: Jun 11 2021<br \/>\nNow time is: 08:58:39<br \/>\nCurrent line number: 7<br \/>\nCompilation Success: 1<\/p>\n<\/div>\n<h3>Preprocessor Operators in C<\/h3>\n<p>There are various operators that help to create macros.<\/p>\n<h4>1. Macro Continuation(\/) operator in C<\/h4>\n<p>Mainly used to continue a macro which is too long to a single line.<\/p>\n<p><strong>Example:- Macro Continuation<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#define  message_of_the_day(i, j)  \\\n   printf(#i \" and \" #j \": TechVidvan Tutorial: Macro Continuation!\")\n<\/pre>\n<h4>2. Stringize Operator(#) in C<\/h4>\n<p>The main purpose of this operator is to convert a macro parameter into a string.<\/p>\n<p><strong>Example of Stringize Operator<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n#define statement(i)  \\\n  printf(#i \": Macro Stringize!\\n\")\n \nint main(void) {\n   statement(TechVidvan Tutorial);\n   return 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">TechVidvan Tutorial: Macro Stringize!<\/div>\n<h4>3. Defined() Operator in C<\/h4>\n<p>Mainly used to determine if an identifier is defined. If it is defined, then the value will be non-zero.<\/p>\n<p><strong>Example:- Defined() Operator<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n#if !defined (MSG)\n   #define MSG \"Macro Defined() operator!\"\n#endif\n\nint main(void) {\n   printf(\"TechVidvan Tutorial: %s\\n\", MSG);  \n   return 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">TechVidvan Tutorial: Macro Defined() operator!<\/div>\n<h4>4. Token Pasting(##) Operator in C<\/h4>\n<p>Mainly used to combine two arguments.<\/p>\n<p><strong>Example:- Macro Token Pasting<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n#define tokenpaster(num) printf (\"token\" #num \" = %d\", token##num)\nint main(void) {\nint token1 = 21;\nprintf(\"TechVidvan Tutorial: Token Pasting(##) operator\\n\\n\");\n   tokenpaster(1);\n   return 0;\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Token Pasting(##) operator<\/p>\n<p>token1 = 21<\/p>\n<\/div>\n<h3>Summary<\/h3>\n<p>There are 4 main types of preprocessor directives in C. Preprocessor allows you to define macros that transform your program before it is compiled.<\/p>\n<p>Programmers use macros to execute pieces of code inside the macro. The #define directive is used to define a macro. \u2018Pre\u2019 means before and \u2018processor\u2019 means making something.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In C, preprocessors are one of the most important and useful concepts. Preprocessor allows you to define macros that transform your program before it is compiled. C preprocessor is also known as CPP. What&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":81689,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3510],"tags":[3729,3730,3731,3732,3733,3734],"class_list":["post-81477","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-conditional-compilation-in-c","tag-file-inclusion-in-c","tag-macros-in-c","tag-preprocessor-directives-in-c","tag-preprocessors-in-c","tag-types-of-preprocessor-in-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Preprocessors in C - TechVidvan<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Preprocessors in C - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"In C, preprocessors are one of the most important and useful concepts. Preprocessor allows you to define macros that transform your program before it is compiled. C preprocessor is also known as CPP. What&#046;&#046;&#046;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-06T03:30:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Preprocessors-in-C.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Preprocessors in C - TechVidvan","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:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/","og_locale":"en_US","og_type":"article","og_title":"Preprocessors in C - TechVidvan","og_description":"In C, preprocessors are one of the most important and useful concepts. Preprocessor allows you to define macros that transform your program before it is compiled. C preprocessor is also known as CPP. What&#46;&#46;&#46;","og_url":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-07-06T03:30:57+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Preprocessors-in-C.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Preprocessors in C","datePublished":"2021-07-06T03:30:57+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/"},"wordCount":1533,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Preprocessors-in-C.jpg","keywords":["Conditional Compilation in C","File Inclusion in C","Macros in C","Preprocessor directives in C","Preprocessors in C","Types of Preprocessor in C"],"articleSection":["C Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/","url":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/","name":"Preprocessors in C - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Preprocessors-in-C.jpg","datePublished":"2021-07-06T03:30:57+00:00","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Preprocessors-in-C.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Preprocessors-in-C.jpg","width":1200,"height":628,"caption":"Preprocessors in C"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/preprocessors-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Preprocessors in C"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/81477","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=81477"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/81477\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/81689"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=81477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=81477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=81477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}