Arduino programming guide series
What is the "_t" in "uint8_t"
The Arduino language contains several easily recognizable variables, like "bool", "byte", "int" and "char". But, below the surface, the Arduino language is really a subset of the C language that works on microcontrollers. With it, you will find many specialized data types designed to ensure compatibility across devices that don't always treat a byte the same way.
If you have looked at more advanced Arduino code, perhaps looking at Arduino sources on Github, you may have noticed that a lot of variable types end with "_t".
You probably already know that the Arduino "language" is based on the C language. I am not exaggerating when I say that our modern civilization depends on C and its object-oriented cousin, C++. No matter what gadget (computer, tablet, phone) you are reading this on, your electronic device functionality infrastructure is written in C and C++.
Because C and C++ is used on so many different platforms, from microcontrollers to supercomputers, there was a need for types (like integers, floats, etc.) that are compatible across all these platforms.
So, in the C99 standard (the ISO standard for the C language), types that are designed to be cross-platform compatible are marked with a "_t". "t" stands for "type."
This way, the programmers know that the uint8_t is a byte with 8 bits no matter which platform the program runs on.
If you strive to write code that can be executed on different computer or microcontroller systems, then it is good practice to use data types with the "_t" extension for this reason.
For the Arduino, we tend not to use C99 cross-platform compatible types because most often our code is not meant to run on other systems.
"Arduino programming" series
Jump to another article
New to the Arduino?
Arduino Step by Step Getting Started is our most popular course for beginners.
This course is packed with high-quality video, mini-projects, and everything you need to learn Arduino from the ground up. We'll help you get started and at every step with top-notch instruction and our super-helpful course discussion space.