platformio / platform-atmelsam

Atmel SAM: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelsam
Apache License 2.0
79 stars 105 forks source link

Intellisense thinks sizeof(uint32_t) != 4 bytes #79

Open ethanjli opened 4 years ago

ethanjli commented 4 years ago

Hi! I'm new to PlatformIO so I'm not sure if this is the right place to post this Intellisense bug which seems specific to the atmelsam platform: On the Arduino Due, int size is 32 bits (4 bytes), and uint32_t size is indeed 32 bits. However, the Intellisense code hints suggest that uint32_t is defined as an unsigned long (via the __UINT32_TYPE__ gcc macro) rather than an unsigned int, and it thinks that uint32_t size is 8 bytes; this appears to disagree with the actual compiler behavior. This Intellisense bug caused me to waste some troubleshooting time under the belief that the compiler had an incorrect definition of uint32_t for the Arduino Due.

A main.cpp as a minimal test case:

#include <stdint.h>

void setup() {
  // put your setup code here, to run once:
  static_assert(sizeof(uint32_t) == 4, "uint32_t size is not 4 bytes!");
  static_assert(sizeof(uint32_t) == 8, "uint32_t size is not 8 bytes!");
}

void loop() {
  // put your main code here, to run repeatedly:

}

Intellisense hints incorrectly show that uint32_t size is an unsigned long of size 8 bytes, not an unsigned int of size 4 bytes: intellisense 1 intellisense 2 intellisense 3

Compilation output correctly shows that uint32_t size is 4 bytes, not 8 bytes:

Compiling .pio/build/dueUSB/src/main.cpp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:6:3: error: static assertion failed: uint32_t size is not 8 bytes!
   static_assert(sizeof(uint32_t) == 8, "uint32_t size is not 8 bytes!");
   ^~~~~~~~~~~~~

VS Code version: 1.38.0 OS: Linux x64 5.0.0-27-generic PlatformIO version: 4.0.3 atmelsam version: 3.8.0 toolchain-gccarmnoneeabi version: 1.70201.0 framework-arduinosam version: 4.3.190711 platformio.ini:

[env:dueUSB]
platform = atmelsam
board = dueUSB
framework = arduino
vhext commented 3 weeks ago

Although it has been a long time, but l get this Intellisense error too on esp-idf :)