Including header files to project src dir without messing with code linter

Why It is not possible to include a simple header file to project in the same dir of a .ino file?

main.ino <- #include “headerfile.h”

This builds fine and code linter rejects it. (file not found)

src
|_main.ino
|_headerfile.h


This builds fine and code linter accepts it.

lib
|_someDir
|_headerfile.h
src
|_main.ino


This builds fine and code linter accepts it.

on platformio.ini env

build_flags = -Ipath_to_project/src/

Please open an issue here Issues · platformio/platformio-core · GitHub . Looks like a bug in PlatfomIO CLI project generator.

Thanks a lot!

Sorry, could you try to rename “INO” to “CPP”?

@ivankravets
The problem of using cpp is that the method prototypes are not generated to “tmp_ino_to.cpp” you have to do it in a separated header file or in the beginning of the cpp file. That is standard c/c++ way.

In Arduino way, you only have an ino file and the method prototypes are generated in the compiler.

I have another issue in linter using .ino files
If you call a method before it is declared in the .ino file the code linter reports method not found. That’s obvious because there’s no prototypes or methods loaded before.

May I suggest a temporary fix for that: generate an invisible prototype header file and include in code linter everytime a new method is created. That seems impossible to accomplish because in larger files it will cause lag. Instead everytime the file is build include that invisible file to get rid of linter errors.

I’ve just fixed this bug. Please go to Menu: PlatformIO > Settings > PlatformIO IDE and check “Use development version of PlatformIO”. Then, Menu: PlatformIO > Rebuild C/C++ Project Index.

INO - this is a “crutch”. Don’t use it. the C/C++ Code Completion and Linter work only with VALID C/C++ files. If you still want to use INO files and to have enabled Code Linter, please take a look at this known issue: Smart Code Linter is disabled for Arduino files.

It isn’t working :frowning:

Menu: PlatformIO > Homescreen. What is PlatformIO CLI version?

ide 1.2.2
and
CLI 2.9.1 version

Do you have a few PlatformIO CLI in your system? Please open system terminal and delete all global PlatformIO CLI:

pip uninstall platformio

sudo -H pip uninstall platformio
Successfully uninstalled platformio-2.9.2.dev0
sudo -H pip install -U https://github.com/platformio/platformio/archive/develop.zip
Successfully installed platformio-2.9.2.dev0

IDE 1.2.2 | CLI 2.9.1

Stop… PlatformIO IDE has built-in PlatformIO CLI. You don’t need to install it separately. We write about it in documentation.

  1. Open system terminal and sudo -H pip uninstall platformio
  2. Open PlatformIO IDE, Menu: PlatformIO > Settings > PlatformIO IDE and check Use development version....

HA! It’s working now

but the home screen version only updated when I restart Atom. Thank you very much!

Thank you too that reported this issue!

Happy Coding with PlatformIO! :blush:

Thank you, one more thing is there a way to include a menu to generate prototypes to an header file from cpp files like ino files does?

Sorry, we don’t have this functionality :frowning: