Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Intellisense goes haywire when adding ".c" file (Read 199 times)
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Intellisense goes haywire when adding ".c" file
Jun 21st, 2022 at 11:40pm
 
Using Visual Studio 2019 with perpetual VSMicro license.  When I try and add a ".c" source file, the intellisense goes completely haywire.  CPP files are no problem.  I am just creating a new project, and using the "Add Empty Arduino C and Header File" menu option.  It breaks auto complete as well.
Back to top
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Re: Intellisense goes haywire when adding ".c" file
Reply #1 - Jun 21st, 2022 at 11:42pm
 
Here it is before I add the ".c" file.
Back to top
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11355
United Kingdom
Re: Intellisense goes haywire when adding ".c" file
Reply #2 - Jun 22nd, 2022 at 12:38am
 
The Arduino .ino code is compiled as C++. You can add C++ files with extern or static methods if you don't want to use classes.

It is often a long complicated discussion to mix c++ and c. However, if you're not absolutely set on using C, then I would recommend you just use the Arduino Programming Language/C++ in the .ino files of the sketch alongside cpp/h files.

if you want to use a function defined in a .c file in a .ino file you need to wrap the prototype in extern "C" {}.

Does this help?
Back to top
« Last Edit: Jun 22nd, 2022 at 12:41am by Tim@Visual Micro »  

Tim Leek
home
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Re: Intellisense goes haywire when adding ".c" file
Reply #3 - Jun 22nd, 2022 at 2:52am
 
That of-course works as there is no problem with cpp files. I was hoping to keep my files more portable though.

Seems there should be no problem with using "C" files from "C++", it's quite common.  It's just the other way around that's difficult.
Back to top
 
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11355
United Kingdom
Re: Intellisense goes haywire when adding ".c" file
Reply #4 - Jun 23rd, 2022 at 12:44am
 
We will look into it thanks
Back to top
 

Tim Leek
home
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Re: Intellisense goes haywire when adding ".c" file
Reply #5 - Jun 23rd, 2022 at 12:56am
 
Great thanks!

I use VisualGDB too but I have to say, for arduino projects VMicro has it beat by quite a bit!
Back to top
 
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11355
United Kingdom
Re: Intellisense goes haywire when adding ".c" file
Reply #6 - Jun 23rd, 2022 at 2:08am
 
We have tested this and can not repoduce the issue.

Can you please send a simple test example project to the email address in the yellow area above

Thanks
Back to top
 

Tim Leek
home
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Re: Intellisense goes haywire when adding ".c" file
Reply #7 - Jun 23rd, 2022 at 6:00pm
 
Done!  Here it is in duplicate:

Google drive link to project:
https://drive.google.com/file/d/1bM2WTdVUggr7khzkjLL7JSRO33wSANyv/view?usp=shari...

Forum Reference:
https://www.visualmicro.com/forums/YaBB.pl?num=1655851254/6#6

Steps To Reproduce:
Board: Seeeduino XIAO (seeeduino_seeed_xiao_m0)
1) Delete .vs, __vm, Debug, and Release directories
2) Load Solution
3) Open TestCFiles.ino
4) Rebuild Solution
5) "memcpy" call will get red squiggles (this is due to an unrelated error in ".TestCFiles.vsarduino.h")
6) Open "MyCFile.c" in the Source Folder (wait for the pointer to change back to an arrow)
7) Switch back to the "TestCFiles.ino" tab

Regards,
Travis
Back to top
« Last Edit: Jun 23rd, 2022 at 6:01pm by DisplayNamesSuck »  
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11355
United Kingdom
Re: Intellisense goes haywire when adding ".c" file
Reply #8 - Jun 24th, 2022 at 6:50pm
 
Back to top
 

Tim Leek
home
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Re: Intellisense goes haywire when adding ".c" file
Reply #9 - Jun 24th, 2022 at 10:18pm
 
Visual.Micro.Arduino.Studio_22_06_11_1901.vsix
This fixes the problems with the ".vsarduino.h" file but not the intellisense problem.

Back to top
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11355
United Kingdom
Re: Intellisense goes haywire when adding ".c" file
Reply #10 - Jun 24th, 2022 at 11:06pm
 
We aren't seeing the issue. It is possible vs has become confused. Here are a few pointers

1) When you build the project intellisense is reset. Did you try a build since the issue started?
2) If the solution is closed and the .vs folder is deleted from below the project that will cause vs to recreate the database for that project when it next opens.
3) Confirm which version of VS you are using. They have improved the intellisense over time. Are you on a 16.11 x version, see help>about.
4) If you right click the project and switch the "CLanguage Standard" to something else, then back again does that resolve? The project properties are used for intellisense only, they don't affect builds. You can experiment but if you switch away from Application.exe visual micro will go to sleep. Switch back again to resolve.

We have tested with avr and sam and samd boards. Your board is a samd but we might need to see how the seeduino core might affect things. I wouldn't expect it too but it's worth this note.
Back to top
 

Tim Leek
home
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Re: Intellisense goes haywire when adding ".c" file
Reply #11 - Jun 25th, 2022 at 12:17am
 
I delete temporary files and rebuild any time I change something.  I've tried it with an ESP32 DevKit board and Arduino Uno board.  They all have the same problem.  I've even disabled all of my other extensions.

Are you sure your following my steps to reproduce exactly?  You have to open "MyCFile.c" in the source folder, wait a second, then switch back to the TestCFiles.ino tab.

Only think left I can think to do is setup a fresh W10 virtual machine and install VS Community edition and see if the problem is still there.

The behavior is slightly different depending on the board, I can't make much sense of it which is why I use the word "haywire".

For an arduino uno, it suddenly thinks that "bool" is a method?!

As soon as I remove MyCFile.c from the project, everything goes back to normal almost instantly.

Screen shot is with an Arduino Uno Board
Back to top
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Re: Intellisense goes haywire when adding ".c" file
Reply #12 - Jun 25th, 2022 at 1:46am
 
This is definitely a bug in vMicro.  I just install a fresh W10 Pro virtual machine and VS Community edition 2022 and it still messes up the intellisense when I add a ".c" file.  The results for arduino uno were again slightly different. Attached are some other images of when I move the cursor over different things.
Back to top
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11355
United Kingdom
Re: Intellisense goes haywire when adding ".c" file
Reply #13 - Jun 26th, 2022 at 9:09pm
 
We currently just use the standard VC++ intellisense. All we do is give VS #defines and lib paths. There is also some redefinition of some gcc syntax that VC++ doesn't understand. None of our own code is running in any of your code/intellisense images.

You might find it works better in VS2022 but we will retest this week to see if we can give VS better defines or includes.

I didn't see the version of VS you have installed. VS2019 has been out for a long time so the exact version might be important. Or click check for updates to ensure VS is up to date.

Confirm which version of VS you are using. They have improved the intellisense over time. Are you on a 16.11 x version, see help>about??


We are also working on an alternative system via the newer "Visual Studio > Open Folder" functionality. Hopefully that will be available during the next month or so, the folder only system allows us to point to the correct gcc toolchain and it will then use that toolchain to give more robust gcc intellisense.  That said, we still can't reproduce an intellisense issue with .c files.

Did you give us the build output mentioned in yellow above, I can't recall. This would allow us to ensure we are using the same toolchain version.
Back to top
« Last Edit: Jun 26th, 2022 at 9:13pm by Tim@Visual Micro »  

Tim Leek
home
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline



Posts: 11
Re: Intellisense goes haywire when adding ".c" file
Reply #14 - Jun 27th, 2022 at 3:45am
 
I emailed the entire VS2019 build output and project to you.  It is also at a google drive link here in this thread.  My VS2019 Pro is up-to-date (16.11.16).  I have also reproduce this problem on VS2022 community edition using a clean Windows 10 Pro virtual machine and the newest 2022 vMicro plugin from this forum. There is nothing else on it!  IE: This is not something that is just magically appearing on my machine. This can be reproduced anywhere on anyones PC if they follow my steps to reproduce correctly.

I can create C++ projects for other platforms, add "C" files and the "standard VC++ intellisense" works great.
Back to top
 
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11355
United Kingdom
Re: Intellisense goes haywire when adding ".c" file
Reply #15 - Jun 27th, 2022 at 2:38pm
 
Thanks we will look. It does look okay in Vs2022. You are using VS2019.

fyi: The different between normal VC++ and Arduino project is simply that the Arduino core has Gcc code in it. Some Gcc code can't be understood by the VC++ intellisense engine. However it should work a lot better with a .c file than you are seeing.

The Visual Micro extension does exactly the same things in both Vs2022 and Vs2019. This thread is about how VS handles things.
Back to top
« Last Edit: Jun 27th, 2022 at 2:39pm by Tim@Visual Micro »  

Tim Leek
home
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline



Posts: 11355
United Kingdom
Re: Intellisense goes haywire when adding ".c" file
Reply #16 - Yesterday at 1:47am
 
We managed to reproduce. Vs is getting very confused. Simply rename he file between .c and .cpp and the issue can happen.

See if the solution in the attached image works. It does for us, if it does then we will try to force the change of file type in the Project Properties Window (tool window F4)

The type property is used for intellisense only, will not affect builds.

Back to top
 

Please Register or Login to the Forum to see File Attachments

Tim Leek
home
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print