-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intellisense in Platformio IDE (VS Code) #1306
Comments
Your assessment is correct, see platformio/platformio-vscode-ide#378 |
I found workaround solution: place #include preprocessor directives for every .ino file you use when editing the code, then when compiling simply comment out these includes. |
I don't think that's an option. Maybe we should move all .ino files to .cpp? |
Only might-be downside is lto, as every file will be different .o extern void setup();
extern void loop(); |
It would be awesome to move to |
C/C++ for Visual Studio Code version 0.21.0 was just released (https://github.com/Microsoft/vscode-cpptools/releases/tag/0.21.0) I think this is another argument for moving from .ino to .cpp. |
I still wonder if definitions can show up by using Regarding the switch, bare minimum to do is to move forward declarations from prototypes.h to somewhere in the include search-path and name them like relay.h, button.h etc. |
I second that. It would make the project more cpp-friendly. |
@mcspr can I help in any way? |
By having prototypes I mean that every public module method should have a declaration before implementation, so other things can refer to it during compilation: # foo.h
#include <iostream>
void foo(int);
# some_other_module.cpp
#include "foo.h"
void foobar() {
foo(100)
} Let's start with this maybe. |
Espurna is a huge project, its not feasible to develop such projects in Arduino IDE, so why the ino files, is this a legacy issue? |
@ali80 There is a workaround, albeit it might seem convoluted at first. Just check out what One tricky thing is to specify every used library manually, as PIO won't do it on it's own for some reason:
As mentioned above, we also need to add: "forcedInclude": ["${workspaceFolder}/espurna/config/all.h"], We can hit an issue with conflicting directories that reference git and non-git versions of libraries, which is not easily discoverable outside of PIO runtime e.g. I do try to use vscode from time to time, but I mostly end up using it for host-built code examples that are later c/p here. vim + ctags over code+libraries otherwise help out to remember how APIs work. Which is a questionable practice to expect from newcomers, that is true. |
@mcspr I deveoped faily big projects with PIO in VScode and and it's automatic dependency detection is pretty good(with cpp files), I think the main issue is the ino files which are different from standard cpp files and PIO would merge all of them before starting the compiler, this this a non standard step specific to arduino platform and ino files, vscode intellisense wont work without this merge. also this might be the reason why pio dependency detection doesnt work on this project. So to make the it work I would manually include all the ino files in the espurna.ino but only for intellisense and not for the actual compilation since they would be readded again and cause error. What I did was search for all the ino files in the project, included all of them after all the includes in the list of the included ino files: // THIS SECTION IS ONLY INCLUDED IN INTELLISENSE
#ifdef __ESPURNA_INT_FIX
#include "utils.ino"
#include "web.ino"
#include "uartmqtt.ino"
#include "tuya.ino"
#include "thinkspeak.ino"
#include "thermostat.ino"
#include "terminal.ino"
#include "system.ino"
#include "telnet.ino"
#include "storage_eeprom.ino"
#include "ssdp.ino"
#include "settings.ino"
#include "scheduler.ino"
#include "sensor.ino"
#include "rpnrules.ino"
#include "rtcmem.ino"
#include "rfm69.ino"
#include "rpc.ino"
#include "rfbridge.ino"
#include "relay.ino"
#include "ota_web.ino"
#include "ota_arduinoota.ino"
#include "ota_asynctcp.ino"
#include "ota_httpupdate.ino"
#include "ota.ino"
#include "ntp.ino"
#include "ntp_legacy.ino"
#include "mqtt.ino"
#include "netbios.ino"
#include "nofuss.ino"
#include "mdns.ino"
#include "migrate.ino"
#include "light.ino"
#include "lightfox.ino"
#include "llmnr.ino"
#include "led.ino"
#include "ir.ino"
#include "i2c.ino"
#include "influxdb.ino"
#include "homeassistant.ino"
#include "gpio.ino"
#include "domoticz.ino"
#include "encoder.ino"
#include "debug.ino"
#include "crash.ino"
#include "button.ino"
#include "board.ino"
#include "api.ino"
#include "alexa.ino"
#include "ws.ino"
#include "wifi.ino"
#endif // end of INTELLISENSE ONLY SECTION So why the ino files? I think using the cpp instead would fix all of this |
True, effectively you can see everything that PIO generates inside of In general .ino has over .cpp:
Nonetheless, I will try out conversion, but I already stumbled upon recursive include problem :) |
thanks for mentioning it, but it would be dangerous if it actually makes a difference I think ino files should actually be slower to compile since a single change anywhere in the code (ino file) would result in the recompile of the large merged file most modern languages dont need forward declares for functions (I think compilers of c era where simple and lean and moved this to programmer side to make compiler job easier) but it is so little to pay to write standard at this point your
now if this works this is a standard cpp project and then you can think of which implementaions to move out of well this doesn't work, too many forward declarations needed :) |
After opening the espurna project in platformio IDE code completion doesn't work like with regular Platformio projects (mutiple .cpp files). I believe the problem stems from espurna being built using multiple .ino files. Is there any way to enable full code completion in VS Code editor? I tried setting "C_Cpp.intelliSenseEngineFallback": "Disabled" flag in settings.json, but it shows multiple errors with the code.
The text was updated successfully, but these errors were encountered: