No member named [blank] in the global namespace - Teensy 4.0

Hello,

So I’m a newbie to PlatformIO but I’ve had no problems with it besides this ‘clang-diagnostic error’ I get when using the IDE in vscode.

These are the error I’m getting:

cstdlib(144, 11): no member named 'calloc' in the global namespace

cstdlib(151, 11): no member named 'malloc' in the global namespace

cstdlib(164, 11): no member named 'realloc' in the global namespace; did you mean 'reallocf'?

stdlib.h(148, 7): 'reallocf' declared here

new(89, 14): enumeration redeclared with different underlying type 'size_t' (aka 'unsigned int') (was 'unsigned long long')

new(126, 26): 'operator new' takes type size_t ('unsigned long long') as first parameter

new(128, 26): 'operator new[]' takes type size_t ('unsigned long long') as first parameter

new(140, 26): 'operator new' takes type size_t ('unsigned long long') as first parameter

new(142, 26): 'operator new[]' takes type size_t ('unsigned long long') as first parameter

new(149, 57): no type named 'align_val_t' in namespace 'std'

new(151, 57): no type named 'align_val_t' in namespace 'std'

new(153, 34): no type named 'align_val_t' in namespace 'std'

stdlib.h(59, 12): no member named 'calloc' in namespace 'std'

stdlib.h(65, 12): no member named 'malloc' in namespace 'std'

stdlib.h(73, 12): no member named 'realloc' in namespace 'std'; did you mean 'reallocf'?

cstdlib(164, 11): 'reallocf' declared here

stdlib.h(91, 27): expected function body after function declarator

_ansi.h(27, 18): expanded from macro '_NOTHROW'

stdlib.h(108, 71): expected function body after function declarator

_ansi.h(27, 18): expanded from macro '_NOTHROW'

stdlib.h(145, 66): expected function body after function declarator

_ansi.h(27, 18): expanded from macro '_NOTHROW'

stddef.h(209, 23): typedef redefinition with different types ('unsigned int' vs 'unsigned long long')

The program itself has no errors, it compiles and uploads just fine and does exactly what’s expected. I’m just confused as to how to get rid of these errors.

If needed, this is my platformio.ini:

[env:teensy40]
platform = teensy
board = teensy40
framework = arduino
lib_deps =
sparkfun/SX1509 IO Expander@^3.0.5
pololu/VL53L0X@^1.3.1
pololu/VL53L1X@^1.3.1
Wire@^1.0

Any help would be mighty appreciated.

Please show a screenshot of the list of all installed VSCode extensions.

I think what’s happening here is that you have a “clangd” extension or something installed, and it very much conflicts with the regular C/C++ extension my Microsoft for intellisense or providing diagnostic error. The clangd extension also won’t be able to deduce much without a config file and might be throwing all these false-positives.

Currently, what I’ve got enabled is:

  • Better Comments
  • Black Formatter (for Python)
  • C/C++ Extension Pack
  • CMake
  • CMake Tools
  • cmake-format
  • Code Runner
  • Code Snap
  • Data Wrangler
  • Excel Viewer
  • Github Repositories
  • Gitlens
  • isort
  • Jupyter (the extension pack)
  • LaTeX Workshop
  • LaTeX Utilities
  • LTeX+
  • Material Icon Theme
  • Material Product Icons
  • Nsight VSCode Edition
  • One Dark Pro Monokai Darker
  • Peacock
  • PlatformIO IDE
  • Python (the extension pack)
  • Rainbow CSV
  • Remote Development (the extension pack)
  • Serial Monitor

I don’t have “clangd” installed but along those lines, could it be CMake/CMake Tools?

As a test, deactivate all extensions except “PlatformIO” and “C/C++ by Microsoft” for your workspace, then reload the VSCode windows (Ctrl+Shift+P → Reload Window). Do a clean compile and build again. Are the errors still there?

The error still persists after disabling all but those two extensions

Where do those errors appear? Can you take a screenshot?

Did you Ctrl+Shift+P → Rebuild Intellisense?

Rebuilding the Intellisense Index does nothing unfortunately.

Here is the screenshot, they appear when hovering over that error squiggle on the “#include <Arduino.h>”:

Is this Microsoft VSCode or VSCodium? What does Help → About say?

I am using Microsoft VSCode.

Here is what About says:
image

I also have these errors on my instance with all extensions disabled apart from the ones required:
C/C++ V1.21.6
C/C++ Extension Pack v1.3.0
PlatformIO IDE v3.3.3

Figured it out: It’s due to this setting ID
C_Cpp.codeAnalysis.clangTidy.enabled

yes that is the problem indeed. Not sure how much not having clang-tidy enabled will affect me but we shall see. Thanks for sorting this out!

No problem. More of a workaround than a solution.

If anyone has any ideas on the correct setup for PlatformIO that they could share without affecting any other extensions, it would be appreciated.

1 Like