{"id":17,"date":"2010-06-09T08:46:09","date_gmt":"2010-06-09T08:46:09","guid":{"rendered":"http:\/\/www.electronic-products-development.com\/?p=17"},"modified":"2024-01-19T09:46:37","modified_gmt":"2024-01-19T09:46:37","slug":"defines","status":"publish","type":"post","link":"https:\/\/ibex.tech\/c\/c\/define\/defines","title":{"rendered":"Defines"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">General Define Usage<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Create a define<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>#define\tSENS_RH_IS_USED     \/\/Comment out or include\n#define\tNUM_OF_ANODES\t2<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Use a define<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>#if NUM_OF_ANODES == 2\n#endif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#ifdef\n#endif\n\n#ifndef\n#endif\n\n#ifdef\n#elif           \/\/Don't use \"#else if\", its actually interpreted as just #else\n#else\n#endif\n\n#if defined(PIC18F87J50_PIM) || defined(PIC18F46J50_PIM) || defined(PIC18F_STARTER_KIT_1)\n#endif\n\n#if defined(SENS_RH_IS_USED) &amp;&amp; (SENS_RH_MODEL == 2)\n#endif\n\n#if defined(ENABLE_SENSOR) &amp;&amp; !defined(__JTAG_DEBUG)\n#endif<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Define if not already defined<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>#ifndef MY_DEFINE_NAME\n    #define MY_DEFINE_NAME    1\n#endif<\/code><\/pre>\n\n\n\n<p>Define using another define<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define MY_DEFINE_1\t\tMY_DEFINE_2<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Multi Line Continuation Character<\/h4>\n\n\n\n<p>Use the &#8216;\\&#8217; backslash character at the end of each line except for the last.<br>If you have any comments surround them with \/* *\/ (don&#8217;t use \/\/ )<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Can you use string in an &#8216;#if&#8217; statement in C programming?<\/h4>\n\n\n\n<p>No, strings are not supported by C. Use something like this instead:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define SCD30           0\n#define AM2322          1\n#define DHT20           2\n#define COMBO_SENSOR_SENORS_FITTED          SCD30      \/\/&lt;&lt;&lt;&lt;&lt;SET SENSOR IN USE (SCD30 or AM2322 or DHT20)\n\n#if COMBO_SENSOR_SENORS_FITTED == AM2322\n\n#elif COMBO_SENSOR_SENORS_FITTED == DHT20\n\n#endif<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>General Define Usage Create a define Use a define Define if not already defined Define using another define Multi Line Continuation Character Use the &#8216;\\&#8217; backslash character at the end of each line except for the last.If you have any comments surround them with \/* *\/ (don&#8217;t use \/\/ ) Can you use string in [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-define"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":14,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":1516,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/17\/revisions\/1516"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/media?parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/categories?post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/tags?post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}