[Solved]Typedef uint16_t on ARM

Hi,

I just came across Embeetle. I created a new project for my RPi Pico and then copied the code of one of my favorite projects into it. This project uses a library that uses the C++ typedefs uint16_t and uint8_t. Which immediately caused type name compiler errors. This project is currently maintained using the Arduino IDE. I did not import it because the Arduino importer only supports Arduino boards.

What would be the way forward on the compiler errors?

Compiler Toolchain : gnu_arm_toolchain_10.3.1_20210824_32b

Hi Adventurer, thanks for reporting this.

I will need some more details to understand what is going on.

The easiest way - if possible - would be for you to share the project. That way, I can reproduce the problem here and check all the details. It doesn’t need to be the full project. You can remove any confidential code, as long as the type name errors occur.

Alternatively, I will need to ask for more details. Let’s start with the basics.

  • what exactly are the errors you get?
  • are these errors in the Embeetle diagnostic window, or during compilation, or both?
  • is the compiler toolchain you mention the one that is used in Embeetle? If so, then which toolchain was used to compile this code in Arduino?

Here is some background. I am just guessing here as to what might be relevant for your issue; I will only be able to judge when I know the details.

uint16_t and uint8_t are normally defined in stdint.h, included using #include <stdint.h>. This header file usually comes together with the compiler toolchain. When you switch to a different compiler, this might cause issues with improperly written C code.

Sometimes, C code will give its own definition for these types, which is strictly speaking not allowed by the different C standards, but is fine as long it doesn’t conflict with the definition in stdint.h. Such code might compile with one compiler and not with another.

Hi,

This particular problem was fixed by using #include <stdint.h>. Thank you.

However, two new problems have emerged. I’ll document those in their own topics.

1 Like