<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>When to use int, const int, const byte and Define</title><link>https://community.element14.com/products/arduino/f/arduino-forum/52729/when-to-use-int-const-int-const-byte-and-define</link><description>I&amp;#39;m not a programmer. I am more of a ressurectionist. I find Arduino code pieces and join them together to make a program like Dr. Frankenstein joined body parts to create his monster. 
 I see the statements listed in the question and wondered when do</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><lastBuildDate>Sun, 09 Apr 2023 19:37:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://community.element14.com/products/arduino/f/arduino-forum/52729/when-to-use-int-const-int-const-byte-and-define" /><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207925?ContentTypeID=1</link><pubDate>Sun, 09 Apr 2023 19:37:24 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:ecfe0376-5e8f-42db-93d9-b8c9c8e548ba</guid><dc:creator>Jan Cumps</dc:creator><description>[quote userid="8791" url="~/products/arduino/f/forum/52729/when-to-use-int-const-int-const-byte-and-define/207923"]btw what to make you Android programing easier?? don&amp;#39;t use void loop()&amp;nbsp; as guess what void loop is a defined macro and invokes main()[/quote]
&lt;p&gt;Are you sure about that one?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207923?ContentTypeID=1</link><pubDate>Sun, 09 Apr 2023 19:25:47 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:c81c0969-ae98-4f70-a888-642717db3454</guid><dc:creator>phoenixcomm</dc:creator><description>&lt;p&gt;I don&amp;#39;t agree, I taught K&amp;amp;R C on the side to students that had one semester. of Pascal. The two languages are very similar in construction ie semantically, even though one is a compiler, and the other is an interpreter. After getting to un-learn Pascals over the use of English to describe variables ( like fred_ponts_to_tom. the #derine though yes I start out with #define FAIL -1&lt;/p&gt;
&lt;p&gt;but in the same had I also showed them things like a square which is #define SQR(a)&amp;nbsp; ((a)*(a)) and also pi see above and for pete sake hallway make your defines in UPPERCASE&lt;/p&gt;
&lt;p&gt;If you try and learn a programing language you need to learn ALL of it. not some of it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;btw what to make you Android programing easier?? don&amp;#39;t use void loop()&amp;nbsp; as guess what void loop is a defined macro and invokes main()&lt;/p&gt;
&lt;p&gt;which means now you can have return codes in main()&amp;nbsp; &amp;nbsp;like int main( ){&amp;nbsp; return FAIL;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207897?ContentTypeID=1</link><pubDate>Sun, 09 Apr 2023 10:07:38 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f681255b-f1f9-49c8-85b9-c354f1723940</guid><dc:creator>obones</dc:creator><description>&lt;p&gt;Yeah, you can do all kind of crazy stuff with the preprocessor, it&amp;#39;s turing complete after all.&lt;/p&gt;
&lt;p&gt;But for a &amp;quot;beginner&amp;#39;s&amp;quot; explanation, seeing it a as copy/paste tool that replaces a given text by another one before sending it to the compiler is a much simpler way to grasp what it does.&lt;/p&gt;
&lt;p&gt;And that also helps a lot understanding why the compiler will emit error messages that never mention the preprocessor symbol, which can be off putting when starting to work with this kind of concepts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207882?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2023 23:29:16 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:35798305-4307-4049-9472-2e6ce76a61e1</guid><dc:creator>Jan Cumps</dc:creator><description>&lt;p&gt;I agree&amp;nbsp;with you on Eclipse, GCC.&lt;/p&gt;
&lt;p&gt;When we switch to the Arduino IDE, Setup(), Loop() and your code, I believe that the Arduino approach is better than what you are doing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207881?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2023 22:28:28 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:cd25ff44-a4d8-48b7-ab06-05b4f1a8216d</guid><dc:creator>phoenixcomm</dc:creator><description>&lt;p&gt;I mess about with this thing. Its fast for running a test. but to get to work please use Eclipse with the GCC toolchain You&amp;#39;ll, thank me.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have several of them one for C, one for Java and I have all of the embedded tools on a third. BTW I despise the Arduino IDE, (all I use is setup(), and then I write my own main() which Loop calls!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207879?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2023 22:21:20 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:0ef5fc81-7730-496e-95ea-a40ded603882</guid><dc:creator>phoenixcomm</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;a href="https://community.element14.com/members/obones"&gt;obones&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
[quote userid="418567" url="~/products/arduino/f/forum/52729/when-to-use-int-const-int-const-byte-and-define/207834"]#define NAME value tells the preprocessor to replace NAME by value wherever it sees it. It is just like copy/paste but done for you by the preprocessor, which means the compiler will never see the NAME item, only a repetition of value in lots of places[/quote]
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sorry you don&amp;#39;t get the star for this, you the&amp;nbsp; Penalty Box. &amp;quot;the #define&amp;quot; is a not copy and paste! It is a MACRO de-expansion tool. please see this example which I posted just before you did. &amp;quot;&lt;span&gt;&amp;nbsp;square #define sqr(a)&amp;nbsp; ((a)*(a)&amp;quot;,&amp;nbsp; this is not copy and paste! just for giggles you can also do pi which is NOT in the Math lib you can do this:&amp;nbsp; #define pi 3.1416&amp;nbsp; kind of this and then nothing is correct you could use this:&amp;nbsp;&lt;span id="MathJax-Span-37" class="mrow"&gt;&lt;span id="MathJax-Span-38" class="mi"&gt;&amp;pi;&lt;/span&gt;&lt;span id="MathJax-Span-39" class="mo"&gt;=&lt;/span&gt;&lt;span id="MathJax-Span-40" class="texatom"&gt;&lt;span id="MathJax-Span-41" class="mrow"&gt;&lt;span id="MathJax-Span-42" class="mi"&gt;atan2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span id="MathJax-Span-43" class="mo"&gt;(&lt;/span&gt;&lt;span id="MathJax-Span-44" class="mn"&gt;0&lt;/span&gt;&lt;span id="MathJax-Span-45" class="mo"&gt;,&lt;/span&gt;&lt;span id="MathJax-Span-46" class="mo"&gt;&amp;minus;&lt;/span&gt;&lt;span id="MathJax-Span-47" class="mn"&gt;1&lt;/span&gt;&lt;span id="MathJax-Span-48" class="mo"&gt;) now turn this into a&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span class="mrow"&gt;&lt;span class="mo"&gt;#define&amp;nbsp; pi&amp;nbsp; atan2(0, -1)&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span class="mrow"&gt;&lt;span class="mo"&gt;Cris.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207870?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2023 13:56:11 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:4d1bc934-2ff5-4092-822a-4b72019d4dd7</guid><dc:creator>shabaz</dc:creator><description>&lt;p&gt;I find the same too! It helps all parties to it. It&amp;#39;s important for startups too, where there may be just one or two developers, it helps all if they use the remainder startup founders (who might not have done as much coding in the past) as their code reviewers, i.e.&amp;nbsp;dragging anyone for a review (doesn&amp;#39;t have to be heavily knowledgeable) it helps in that scenario, simply to speak through&amp;nbsp;the design&amp;nbsp;choices.&amp;nbsp;The same applies for hardware reviews.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207868?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2023 08:44:58 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:d2abca22-aaef-4347-a593-54170a87880f</guid><dc:creator>Jan Cumps</dc:creator><description>[quote userid="123345" url="~/products/arduino/f/forum/52729/when-to-use-int-const-int-const-byte-and-define/207858"]the firm has serious questions to answer, how that passed a code review!&amp;nbsp;[/quote]
&lt;p&gt;side story: I do code reviews in my company as volunteer. Usually when we have third-parties writing customisations for us.&lt;/p&gt;
&lt;p&gt;I learn more than I find issues. Often, externals are certified developers. They are used to write code that will be reviewed. Most things that I send back are magic numbers, arbitrary maximums, and constructs that will cause sustain issues later.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207867?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2023 07:52:47 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:69c3fb8a-462e-496e-9a95-7e5b1eae1ffc</guid><dc:creator>Jan Cumps</dc:creator><description>&lt;p&gt;I&amp;#39;m fond of foo bar. It&amp;#39;s part of it culture. One of the rare moments that there&amp;#39;s some lightness in geek land. It also has a purpose: makes it very clear that a generic / abstract example is given. And recognisable by lovers and haters&amp;nbsp;&lt;span class="emoticon" data-url="https://community.element14.com/cfs-file/__key/system/emoji/1f601.svg" title="Grin"&gt;&amp;#x1f601;&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Other frequent visitors are hello, world!. And scott/tiger will bring warm memories to early Oracle developers. And the blinky.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207863?ContentTypeID=1</link><pubDate>Fri, 07 Apr 2023 06:45:08 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:3c33ecf7-3a52-4333-a532-1512471b37e0</guid><dc:creator>Andrew J</dc:creator><description>&lt;p&gt;Agreed. &amp;nbsp;A lot appear because they are just rehashes of prior examples that don&amp;#39;t really explain, or at least only superficially, a particular problem by people being lazy or trying to appear clever. &amp;nbsp;Thus the incomplete explanations are forever propagated. &amp;nbsp;Where I&amp;#39;ve had to learn something new, I&amp;#39;ve done so with a very specific problem in mind to solve rather than following along blindly with foo and bar nonsense. &amp;nbsp;It helps of course to have the 10,000 hours under my belt so I can cross-relate principles and points. &amp;nbsp;And yet, C pointers......&lt;span class="emoticon" data-url="https://community.element14.com/cfs-file/__key/system/emoji/1f615.svg" title="Confused"&gt;&amp;#x1f615;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;And no, not work related per-se, just something tied to the museum that I&amp;#39;ve agreed to take on. &amp;nbsp;I&amp;#39;ve had to get to grips with PIC microprocessors and development and it was another egregious example of someone trying to be way too clever with their C code and unnecessary embedded assembler. &amp;nbsp;Although in fairness, he&amp;#39;s a really nice chap and genuinely very, very clever so I don&amp;#39;t think he realises!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207858?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 22:19:01 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:c1dd2c62-4e38-4c15-bc8f-df7150b1bf65</guid><dc:creator>shabaz</dc:creator><description>&lt;p&gt;Hehe that&amp;#39;s crazy.&amp;nbsp;I&amp;#39;m guessing it wasn&amp;#39;t work related, or the firm has serious questions to answer, how that passed a code review!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207857?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 22:14:54 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:cd0e91d3-bb1d-4778-82c3-0a421337972c</guid><dc:creator>shabaz</dc:creator><description>&lt;p&gt;Foo and bar are the worst! It never made sense. Reminded me of the stereotype of the nerd who deliberately uses the most complex sed/awk syntax he/she can think of. Especially since it doesn&amp;#39;t take a genius to figure out that foo and bar are not really helping in example code, so it makes me think the author isn&amp;#39;t trying to teach, he/she is trying to sound&amp;nbsp;perhaps trendy in computing circles (and failing).&lt;/p&gt;
&lt;p&gt;I had a habit of simply skipping or mentally trashing any book or guide that used those two particular variables.&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t mind Alice and Bob, at least they simplify understanding networks a bit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207856?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 21:54:27 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:b8d62ed5-2982-40d3-90b0-d75c08c93f4d</guid><dc:creator>beacon_dave</dc:creator><description>&lt;p&gt;It probably doesn&amp;#39;t help that those metasyntactic variable names are often used in code examples in training materials.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207855?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 21:17:19 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:402ecc56-a426-4454-8746-eb00397fcde2</guid><dc:creator>Andrew J</dc:creator><description>&lt;p&gt;Do the right thing and use decent function and variable names. &amp;nbsp;And no none-alphanumeric characters. &amp;nbsp;Also, &amp;nbsp;no including the type in the variable name. &amp;nbsp;&lt;span class="emoticon" data-url="https://community.element14.com/cfs-file/__key/system/emoji/1f603.svg" title="Smiley"&gt;&amp;#x1f603;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ve had to rewrite some code recently and the interrupt service routine was called fred() - guess what it did? &amp;nbsp;Yeh me too. &amp;nbsp;I did work out that it wasn&amp;rsquo;t anything to do with The Flintstones!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207848?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 17:04:24 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:e7a2c715-f24f-4944-bd8f-499eff750df1</guid><dc:creator>colporteur</dc:creator><description>&lt;p&gt;Thank you for the response. This makes sense to me.&lt;/p&gt;
&lt;p&gt;Best Practice (i.e. it has some advantages), get in the habit of using const or #define when identifying the pins.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207845?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 16:43:30 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:eccfde5e-c355-4cd9-9b91-cca37a92c808</guid><dc:creator>shabaz</dc:creator><description>&lt;p&gt;Incidentally this would also help newcomers, to enable AI. But it&amp;#39;s generally a paid thing (but cheap) so I can&amp;#39;t see&amp;nbsp;everyone wanting to use it, especially if they are only interested in the outcome, not the journey toward learning a language (which from my perspective is a fun thing to do, problem-solving by creating your own apps).&lt;/p&gt;
&lt;p&gt;I&amp;#39;m finding I&amp;#39;m discovering new things I didn&amp;#39;t know were possible (for instance in Python, which is still relatively new to me), as well as discovering API or function calls that I didn&amp;#39;t know existed, in packages/libraries for instance. In other words, even though AI is doing some of the work, I&amp;#39;m learning along the way.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207844?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 16:36:58 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1c2d4401-42df-4c28-8aeb-ee9520a99558</guid><dc:creator>shabaz</dc:creator><description>&lt;p&gt;I was pleasantly surprised that PyCharm (amongst other IDEs) highlights variables that are not proper words. Admittedly I still ignore that occasionally.&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" style="max-height:172px;max-width:332px;" height="172" src="https://community.element14.com/resized-image/__size/664x344/__key/communityserver-discussions-components-files/152/pastedimage1680798827511v2.png" width="332"  /&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m finding I&amp;#39;m writing more comments now than before, for one simple reason, which is that it helps AI understand what I want.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using Copilot a lot, and if I type a comment, then the AI starts understanding sooner what I want, so that it can write its own code. Perhaps that will swing developers towards writing more descriptive comments or variable names in future, since it&amp;#39;s inevitable that such AI (especially when any issues that are preventing some orgs to not use it are resolved) will become the norm.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207843?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 16:36:53 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:decebf7a-0479-4060-9cd2-40b24e40ba91</guid><dc:creator>Jan Cumps</dc:creator><description>&lt;p&gt;&lt;a href="https://exelearning.org/wiki/OttingersNaming/"&gt;exelearning.org/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;8. Also Use Problem Domain Names&lt;br /&gt;When there is no `programmer-ese&amp;#39; for what you&amp;#39;re doing, use the name from the problem domain. At least the programmer who maintains your code can ask his boss what it means.&lt;/p&gt;
&lt;p&gt;In analysis, of course, this is the superior rule to (Use #7 Solution Domain Names), because the end-user is the target audience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207842?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 16:33:18 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:40e7153e-31ef-4f48-a529-ffdaa977a77e</guid><dc:creator>Andrew J</dc:creator><description>&lt;p&gt;I wasn&amp;#39;t referring to you specifically, I was being more philosophical, honest. &amp;nbsp;I bet the original &amp;quot;designers&amp;quot; of this thing were C programmers :) &amp;nbsp;They should have been calling them by their proper names for clarity. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;OO does say use domain language but what you have is&amp;nbsp;not a problem domain, it&amp;#39;s a specific instance within the problem domain. &amp;nbsp;My definite knowledge&amp;nbsp;is to also call a Spade a &amp;quot;DiggingImplement spade = new DiggingImpement(BladeType typeOfBlade);&amp;quot; and not a &amp;quot; DigImpl spd = new DigImpl(Blade_t tp);&amp;quot; &amp;nbsp;But then I come from a SmallTalk background which would have been something like spade = new DiggingImplementWithBladeType: bladeType (SmallTalk is untyped because everything, including literal integers for example, are full blown Object or Object subclass instances). &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Anyway, as I say, I was being very generalist: you have to admit, there is a massive tendency in C programming to abbreviate function and variable names and I can&amp;#39;t fathom the reason for it. &amp;nbsp;Except, yes, for MOSI, MISO I would use the same because the designers of that chose to abbreviate and they&amp;nbsp;are absolutely well understood terms and used by everyone (unlike BP2, SRWD, WRDI etc.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207841?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 15:59:51 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:747da448-fc56-443c-8a52-2bb0c6594766</guid><dc:creator>Jan Cumps</dc:creator><description>&lt;p&gt;Not a C thing in this case. A choice:&lt;/p&gt;
&lt;p&gt;I claim that I did not abbreviate anything&amp;nbsp;&lt;span class="emoticon" data-url="https://community.element14.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;. I used the language of the problem domain.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote userid="188728" url="~/products/arduino/f/forum/52729/when-to-use-int-const-int-const-byte-and-define/207840"]Why not readId() {} or bool blockProtectBit2 etc... It feels like it&amp;#39;s some undocumented standard somewhere or some C programmer brotherhood thing! [/quote]
&lt;p&gt;RDID and BP2 are documented. If I use&amp;nbsp;readID and blockProtectBit2, I&amp;#39;d have to document them. I think that it is an advantage of using domain specific lingo. OO advises to use the names of the problem domain.&lt;/p&gt;
&lt;p&gt;If I were to write an abstract Memory class, I&amp;#39;d probably use a different type of name. But this one is close to a particular problem domain and I used their names.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;d do&amp;nbsp;the same with MISO, MOSI, ... . If I write a class that&amp;#39;s a SPI wrapper, I&amp;#39;d call MISO, MOSI, nCS etc.&lt;br /&gt;If I wrote an abstraction layer around serial chip protocols, I&amp;#39;d probably use read(), write(), select()&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207840?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 15:54:29 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:c6f338bb-3ba7-40b9-885e-ad95c2ec54aa</guid><dc:creator>Andrew J</dc:creator><description>&lt;p&gt;Yes, not picking on you &lt;span class="emoticon" data-url="https://community.element14.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Why do C programmers always feel the need to abbreviate the heck out of variable and function names so that they aren&amp;#39;t readily apparent? &amp;nbsp;Why not readId() {} or bool blockProtectBit2 etc... It feels like it&amp;#39;s some undocumented standard somewhere or some C programmer brotherhood thing! &amp;nbsp;It&amp;#39;s not like source code contributes to the final executable size. &amp;nbsp;Or is it that C programmers are unduly lazy and their poor fingers can&amp;#39;t cope with having to type an extra few characters&amp;nbsp;&lt;span class="emoticon" data-url="https://community.element14.com/cfs-file/__key/system/emoji/1f601.svg" title="Grin"&gt;&amp;#x1f601;&lt;/span&gt; &amp;nbsp;Good job they didn&amp;#39;t get into SmallTalk!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207839?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 15:28:24 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:a3c4ed80-a4e6-47ad-82de-f1c22cbdbd75</guid><dc:creator>Jan Cumps</dc:creator><description>&lt;p&gt;&amp;gt; &lt;span&gt;what do functions rdid() and rdsr() do?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s the name&amp;nbsp;of a&amp;nbsp;function you can do with flash.&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" style="max-height:360px;max-width:640px;"  src="https://community.element14.com/resized-image/__size/1280x720/__key/communityserver-discussions-components-files/152/pastedimage1680794768872v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;gt; Ditto set_nhold() and set_nwrite()?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;set the IC&amp;#39;s&amp;nbsp;NHOLD and NWRITE pins&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img loading="lazy" alt="image" style="max-height:250px;max-width:365px;"  height="250" src="https://community.element14.com/resized-image/__size/730x500/__key/communityserver-discussions-components-files/152/pastedimage1680794875000v2.png" width="365" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;gt;&amp;nbsp;What are the purposes of variables srwd, bp2? &amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img loading="lazy" alt="image" style="max-height:431px;max-width:568px;"  height="431" src="https://community.element14.com/resized-image/__size/1136x862/__key/communityserver-discussions-components-files/152/pastedimage1680795090014v1.png" width="568" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I did that deliberately - match the manufacturer&amp;#39;s names.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207834?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 12:54:37 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:953924a4-c146-45c0-a4b3-64272ed1fbf1</guid><dc:creator>obones</dc:creator><description>&lt;p&gt;When compiling, you have multiple steps, three of them being preprocessor, compiler and linker in that order&lt;/p&gt;
&lt;p&gt;The preprocessor takes your source files, modifies them &amp;quot;in memory&amp;quot; and passes the result to the compiler&lt;/p&gt;
&lt;p&gt;The compiler takes its input and generates machine code in the form of object files (.o)&lt;/p&gt;
&lt;p&gt;The linker takes all object files and creates the final application file (.exe under Windows, .bin for firmware...)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;#define NAME value tells the preprocessor to replace NAME by value wherever it sees it. It is just like copy/paste but done for you by the preprocessor, which means the compiler will never see the NAME item, only a repetition of value in lots of places&lt;/p&gt;
&lt;p&gt;const int and int only differ in semantics, the &amp;quot;const&amp;quot; specifier telling the compiler that it should not allow any code to change the value. As this is seen by the compiler, you can &amp;quot;take&amp;quot; the address of the constant by using the ampersand (&amp;amp;) operator, which might be required by some libraries and is even more convenient when dealing with structures because all you deal with is a pointer (32 bits on 32 bits architecture) and not the entire structure itself (that can range in the dozen of bytes)&lt;/p&gt;
&lt;p&gt;Finally, the linker can do some serious optimizations with constants when they have the same value by &amp;quot;merging&amp;quot; them together, meaning that 10 constants with the same value only occupy their size once in the final firmware. While this does not mean much under desktop OSes, it can be very important on embedded architectures.&lt;br /&gt;One other benefit of &amp;quot;const&amp;quot; is that on architectures like the ESP32, the value is not placed in RAM but in Program memory. As RAM is very limited (120k contiguous at most), it is of the utmost importance to place as little things as possible in there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207833?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 07:30:52 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1339ea8d-9626-4c46-8b4c-c5fd1a295b38</guid><dc:creator>beacon_dave</dc:creator><description>&lt;p&gt;5 mins a day would soon get you through it. Time you are likely to get back starting from your next project.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When to use int, const int, const byte and Define</title><link>https://community.element14.com/thread/207832?ContentTypeID=1</link><pubDate>Thu, 06 Apr 2023 03:48:27 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:860e6f32-590a-47da-8366-1d387489e7a5</guid><dc:creator>Prasanth_R</dc:creator><description>&lt;p&gt;Ok, I got your confusion. I created a simple function that prints pin number specified in different data types using &lt;a href="https://godbolt.org/"&gt;Compiler Explorer (godbolt.org)&lt;/a&gt;&lt;br /&gt;As you can see from the assembly language, compiler considers &lt;br /&gt;#define and const declaration as same and directly copy the absolute value to register.&lt;br /&gt;int as a 32bit value (double word).&lt;br /&gt;byte as 8bit value, which compiler copies to lower byte and set 0 to rest of the higher order bytes.&lt;/p&gt;
&lt;p&gt;Considering pin number won&amp;#39;t change during compilation or run time and less amount of processing required pin definition can be made using const or #define types.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="image" style="max-height:360px;max-width:640px;" src="https://community.element14.com/resized-image/__size/1280x720/__key/communityserver-discussions-components-files/152/pastedimage1680752808166v1.png"  /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>