Platform Arduino Framework - function in private library won't detect called in main.ccp by the IDE

Hi there,
I using VS Code IDE with Platform to code an Arduino Board wich works really fine.
No I create an private library for test purpose:

|–lib
| |
| |–Bar
| … |- Bar.cpp
| … |- Bar.h
|
|- platformio.ini
|–src
… |- Bar.cpp
… |- Bar.h
… |- main.c

Bar.h:

#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
/* ^^ these are the include guards */
/* Prototypes for the functions */
int Sum (int a, int b);
int Sub (int a, int b);
int Add (int a, int b);
#endif

Bar.ccp

#include "Bar.h"
int Sum (int a, int b){
 return a + b;
}
int Sub (int a, int b){
      return a - b;
}
int Add (int a, int b){
    return a * b;
}

main.cpp

...
u8x8.println(Sub(10, 5),DEC);
  u8x8.println(Add(10, 5),DEC);
...

Well, what is the problem:
Sometime, e.g. after changing some code section, the IDE reports problem like here:

And sometimes, often after changing, the IDE reports even in the main.cpp that the function I calling e.g. u8x8.println(Sub(10, 5),DEC); is not know.

ALTHOUGH the compiler runs through and upload to device and running of the code was / is successful.

Any Idea?

Only moving the Bar.cpp and Bar.h to the src folder where the main.cpp stay is working:

|–lib
| |
| |–Bar
| … |- Bar.cpp
| … |- Bar.h
|
|- platformio.ini
|–src
… |- Bar.cpp
… |- Bar.h
… |- main.c

I tested your code and saw no problems in the Intellisense.

With the platformio.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino

Note that this in on Windows 10 with VSCode of version 1.50.1.

So I can only recommend to try and rebuild the intellisense (Project Tasks → Miscellaneous → Rebuild Intellise Index) and re-open VSCode.

If that still isn’t working, then I might have been unable to replicate your problem either due to OS or incomplete information (no platformio.ini shown, full source code of main.cpp not shown).

And I really hope it’s main.cpp and not

Because you’re writing against Arduino (C++ framework) and using your own Bar library which is implemented in C++.

Hi Maxgerhardt,

thanks a lot for testing.

Hier my platform.ini

[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
lib_deps =
   olikraus/U8g2@^2.28.8
   adafruit/RTClib@^1.12.0
upload_port=/dev/cu.wchusbserial40120

I’m using macOS Catalina with VSCode Ver. 1.50.1

Well, main.c was a copy past error. In deed, I meant of course main.cpp. :slight_smile:

Rebuilding of intellisens is a great idea. Thanks. But I couldn’t find it. Where exactly it Project Tasks -> Miscellaneous -> Rebuild Intellise Index???

Please follow the link I posted in regards to that.

Alright, thx so much :wink:

The problem message is away! Thank you.