Menu

HarduIno / µC tips: Recent posts

Should I use global or local variables?

Many Arduino tutorials use global variables without really telling why. And since there's no explanation, those snippets contribute to spreading bad coding practices. Here's one of them.

Let's first set the context: since Harduino is a project mostly related to the 8-bit AVR architecture, this article focuses on the latter, mostly. However the generalizations mentioned here do apply to any other — and not limited to 8-bit — architecture although the reader should be wise enough to assess to what extent. The wary developer might argue this is mitigated by compiler optimizations, which could, in some circumstances, make the use of global variables completely irrelevant. However one should understand the consequences of using global variables prior to relying upon optimizations to alleviate them.... read more

Posted by Vince C. 2021-08-21 Labels: global vs local variables
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.