-
Notifications
You must be signed in to change notification settings - Fork 233
The Extension should automagically fill the c_cpp_properties.json, so intellisense works out of the box #438
Comments
Please see here to see whether help resolve this issue? By default, the Arduino extension doesn't pick up all the head files. You can either pop up the command "Arduino: Library Manager" to include the header file to your paths. |
Hi, I just open an example, the blink example, and used the arduino Uno as board. That way, my c_cpp_properties.json has just these two folders:
With that, all the Arduino-defined functions and variables are highlighted as undefined (pinMode, digitalWrite, HIGH,...). It may be that I don't get how this thing is supposed to work, but I expect from the Arduino plugin to get all these methods by default. I also don't understand why doesn't it search for libraries where the Arduino IDE is expecting to find libraries (that is, the installation folder, the roaming/local/... folder where your boards are installed and the sketchbook location). These folders should be added by default. In any case, even if I add them, I can't get it to work. Yes, it compiles, but it's impossible to use this in a medium sized sketch without getting dozens of errors that make debugging a nightmare. If my understanding is correct, only the folders in the includePath parameter are used for intellisense, but the search in them is not recursive. I don't know what folders do I have to add to get all the different definitions and methods and whatnot from Arduino working, but I suspect that it could be again dozens of them, not including all the folders I have to include to make a library work if it has dependencies... Is there a way to get Intellisense working on the Arduino plugin or am I doing something that is simply not achievable? |
I've been fighting the same thing; since the intellisense parser changed to requiring exact paths from being willing to follow recursive directories, it's basically impossible to set up all the include paths necessary for Arduino usage. I've been able to add all the libraries to the browse path, which inexplicably does work with recursion. Then, VS Code will suggest folders that are missing from the include path in the light bulb bubble. But I have to play whack-a-mole going deep into the bowels of included microcontroller library structures to get everything added. And the suggestions stop working after you pick only one, so you end up with lots of missing libraries and no way to discover the necessary paths for them... This really needs to be fixed by the C/C++ extension authors, but judging from their issues database they've seemed stubbornly resistant to feedback requesting the return of recursive search paths. :( |
That's a shame, let's see how things develop, but it looks like a dealbreaker, at least for me at the moment. :( |
Also been fighting this issue. I have been trying to use the LiquidCrystal library for a project of mine, First it's annoying and unwieldy trying to point to that file - let alone dig around to then find (and point to) the dependencies within that. The c_cpp_properties.json file is becoming a mess trying to keep - I'm rather discouraged to work on a bigger project which might need more libraries. Any other solutions or alternatives for now? It's a shame because I love Visual Studio Code and it would be perfect to add another type of project to it (I use it for Unity (C#), Java, and Web Development with zero issues) |
For please this value to your vscode setting file to see whether fix the intellisense issue: "C_Cpp.intelliSenseEngine": "Tag Parser", |
This partially works (In that it stops the problems showing up in my test.ino file; and it seems I can show IntelliSense for methods not affected by problematic includes deeper down the rabbit hole) As you can see It will suffice for now - At least I can program for (and build) to my Arduino from the comfort of VS Code :) Looking forward to see even tighter / full integration soon. Thanks @yaohaizh |
I was in a similar situation trying to set up vscode for programming ESP chips (using Arduino). But it does give me preview for parameters in the FastLED Library, which is installed under Stuff I did:
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.intelliSenseEngine": "Tag Parser",
{
"name": "Arduino",
"includePath": [
"${workspaceRoot}"
],
"browse": {
"path": [
"D:/Program Files (x86)/Arduino/hardware",
"D:/Program Files (x86)/Arduino/libraries",
"D:/Users/Julian/Documents/Arduino/libraries/",
"D:/Users/Julian/Documents/Arduino/hardware/",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"intelliSenseMode": "msvc-x64"
} that way, only the Tag Parses will be used as the engine and the config in the c_cpp_properties.json becomes a lot simples, since intellisense reads directories recursively now. That way I also got the engine to read libraries I installed manually, since they are placed in my homedirectory ( I'm gonna try to config the Arduino extension from Microsoft as well now, if I run into some issues I can fix I will comment them here. |
I have not tried the tag parser setting suggested here, but had come up with a solution which was to simply add all the include paths by hand. For a basic hello world program on a UNO like this:
I need a C_Cpp_properties.json like this:
Maybe changing it so that Arduino: Board Config actually includes all the needed paths could be a start for trying to fix the issue. |
@dafzor Thanks. I adjusted it for linux and it works. At least I got autocompletion and intellisense working. In case someone else needs it, here is my config:
|
Somebody Please tell this for mac too |
I can't find the path for Mac |
@stormbytes I think that is caused because the Arduino.h file isn't included by default in Visual Studio's mind. The Arduino Software obviously includes their core when compiling. |
@stormbytes I'm not using PlatformIO, I'm using the Arduino Extension from Microsoft But I guess both extensions didn't prevent this from happening, oh well not the End of the world |
The official Arduino IDE will include the <Arduino.h> behind in their tooling. But for VSCode Arduino extension, we have to include explicitly, just as normal C/C++ file to make the intellisense work. But you doesn't need this header file for build/upload. |
Just leaving the info here that even if you setup the include paths the intellisense will still not work 100%. For example, if you include SD.h library and a line like this So I ended up moving to http://www.visualmicro.com until the vscode extension gets fixed. |
On macOS, I added
Notice that |
I think you can run {
"configurations": [
{
"name": "Win32",
"defines": [
"F_CPU=16000000L",
"ARDUINO=10805",
"ARDUINO_AVR_UNO",
"ARDUINO_ARCH_AVR"
],
"includePath": [
"D:\\tools\\arduino-1.8.5\\hardware\\arduino\\avr\\cores\\arduino",
"D:\\tools\\arduino-1.8.5\\hardware\\arduino\\avr\\variants\\standard",
"D:\\tools\\arduino-1.8.5\\hardware\\tools\\avr\\avr\\include",
"D:\\tools\\arduino-1.8.5\\hardware\\tools\\avr\\lib\\gcc\\avr\\4.9.2\\include"
],
"browse": {
"limitSymbolsToIncludedHeaders": false,
"path": [
"D:\\tools\\arduino-1.8.5\\hardware\\arduino\\avr\\cores\\arduino",
"D:\\tools\\arduino-1.8.5\\hardware\\arduino\\avr\\variants\\standard",
"D:\\tools\\arduino-1.8.5\\hardware\\tools\\avr\\avr\\include",
"D:\\tools\\arduino-1.8.5\\hardware\\tools\\avr\\lib\\gcc\\avr\\4.9.2\\include"
]
},
"intelliSenseMode": "msvc-x64"
}
],
"version": 3
} |
I also retried today to configure the support for intellisense and it doesn't work. |
If you meet something like I'm not sure if there're other flags like this, while I hope the extension could do this automatically for us, since we have done setup the "Arduino Board Configuration". |
Nope, in my case the problem is the editor. No way to configure properly the intellisense and get rid of the squiggles on the includes |
Which header is trying to request "WProgram.h"? In my linux package, there's no WProgram.h and no header's including it. |
quick search trough the headers shows this bit of code
`* The WProgram.h file, which provides declarations for the Arduino API,
has been renamed to Arduino.h. To create a library that will work in
both Arduino 0022 and Arduino 1.0, you can use an #ifdef that checks
for the ARDUINO constant, which was 22 and is now 100. For example:
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif`
So seems you're using an old library that doesn't properly account for
newer versions of the API.
…On 20 January 2018 at 13:01, Clouds ***@***.***> wrote:
Which header is trying to request "WProgram.h"? In my linux package,
there's no WProgram.h and no header's including it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#438 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABiZrkdbxmzMzogGLcWZFglJqV6CuCn8ks5tMeOSgaJpZM4QSAJ2>
.
|
It's also about defines, the ARDUINO macro is not defined, add
to your c_cpp_properties.json I'm assuming you're using this DHT.h, and your ARDUINO version is 100, change it if necessary. |
Looks far better now, thanks! I don't understand why the vscode extension does not provide somthing to get this easier. Also the doc does is not clear about the settings needed to make it work. |
Still, all the solutions force you to use the tag parser, as the default mode doesn't work. I don't think the issue is solved, as the default mode doesn't work. Even including all the individual paths, I still get errors of undefined stuff that is clearly defined in libraries I'm including. All the best and good luck. |
Another example: |
@adiazulay Has #1183 found it's way into the current release? If so, you can probably close this issue along with #776, #772 and #866. EDIT: Ah sorry, just checked, this seems to only be part of the 0.4rc release right now. |
@iFreilicht if you download it and install the .vsix directly in vs code and let me know it works as expected on your end we could probably get it released today. Otherwise it'll probably be early next week. link to release: https://github.com/microsoft/vscode-arduino/releases/tag/v0.4.0-rc2 |
@adiazulay I tested this with a few boards and it seems to work well, except for #1206 as you reported. I am getting |
I just tried it too, but for some reason the "auto fill" doesn't work for me. |
@Benik3 are you using v0.4.0-rc2? If you are can you try to rebuild intellisense configuration? |
Yep, I installed the version posted above. |
Yes, you can do that, but you have to select a board and serial port again afterwards.
Could you post a link to the .ino file you're having trouble with? I tested this on several of my projects, and couldn't reproduce your issue. And try to run "Verify" once, after that all the library folders should be added! |
I found that in some cases if c_cpp_properties.json was generated with v0.3 you have to delete it for the new one to generate correctly. |
Temperature_logger.zip |
It looks like I found the problem. I didnt know, that I have to make Verify, to init it. So when I wanted to check the configuration, VScode automatically inited the default CPP json. After this, it never re-init as Arduino. After good initiation I really have included libraries folder, ESP8266 definition etc., so it looks good :) I also found, that sometime the Verify is launched automatically (it happen after opening the VScode, opening the example, now it happen immediately after what was manual Verify done). |
Which is why I wrote:
But ok, glad to see you got it working 👍️
Yes, as Adi already explained above:
|
Automagical creation of the
The important one here for the intelligence is the https://www.nongnu.org/avr-libc/user-manual/using_tools.html Long story short, defining the architecture type in
This screenshot shows what kind of an error user would experience if the microcontroller is not defined properly. Most of the C/C++ functions, and Arduino functions would work perfectly, but any pin or bit definitions that are chip specific would fail. The screenshot shows that inteellisense failing to determine the current context and showing all the matching definitions for all AVR family chips. Normally |
v0.4.0-rc3 |
@starofys was the last |
and in boards.txt compiler.libs.c.flags |
@itopaloglu83 Do you know which boards are affected by this? It seems all the regular Arduino boards and a lot of third-party ones work just fine without this definition. |
Uhm, I would say it’s pretty common. Arduino Uno sketches get syntax highlighting errors. Not the missing include statements but the define statements for the pre-compiler. See my message above. |
Alright, thanks. I just wasn't sure because I didn't notice this ever during testing.
15 Mar 2021 19:56:32 Ihsan Topaloglu ***@***.***>:
… Uhm, I would say it’s pretty common. Arduino Uno sketches get syntax highlighting errors. Not the missing include statements but the define statements for the pre-compiler. See my message above.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub[#438 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ACKKSK3QENEOO5CMMUJDCGDTDZJ55ANCNFSM4ECIAJ3A].
[data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgIfAhkiAAAAB9JREFUaIHtwQEBAAAAgiD/r25IQAEAAAAAAAAAAC8GJDAAAY7rwGcAAAAASUVORK5CYII=###24x24:true###][Tracking image][https://github.com/notifications/beacon/ACKKSK2BNGLTG7N3THH47LLTDZJ55A5CNFSM4ECIAJ3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOF6VAHYY.gif]
|
IntelliSense auto-generation has been added in v0.4.0. If you're having any problems with IntelliSense please open a new issue. |
Thank you |
EDIT: 07/03/2018: My understanding of the issue has improved since I opened it. I think that the extension should fill the intellisense config file on the fly based on the board being selected by the user.
To my knowledge, the Arduino IDE checks for libraries in 4 places: the main Arduino installation path (in windows c:\program files....), any board-specific version of the libraries for this board ("...\appdata\local..."), your sketchbook location and a "libraries" folder for that particular sketch. Ideally, you would install your libraries in your sketchbook location, so they are available for all your projects.
I've just installed VS Code and the Arduino plugin, and it seems to be able to know that my sketchbook location is not the default, as I can see the examples of the libraries that I've installed there, and I can compile my sketch. In any case, I get tens of intellisense errors, as intellisense seems incapable to follow the paths for the includes. I can add the sketchbook location libraries to the c_cpp_properties.json, and either add all the libraries used there (painfull) or add the base "libraries" folder and then tweak the includes to have partial paths (less painfull), but even in these cases, intellisense will complain that it can't find any of the libraries this files might use. And I would have to do it for all my projects, one by one.
What am I doing wrong? why doesn't this plugin pick the usual library locations? Is it normal to have 100s of intellisense errors? is that really the way it's meant to be?
Sorry, I'm new to Visual Studio and Visual Studio Code, and I'm quite sure that the problem it's me not being able to find out the logic behind them, but I can't find any info on the internet either.
I'm using windows 10 64 bits, and my arduino Ide is at the latest version. The relevant part of my c_cpp_settings.json of this project is:
This is a screenshot of my project
The text was updated successfully, but these errors were encountered: