Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • 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
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Intellisense goes haywire when adding ".c" file (Read 3706 times)
DisplayNamesSuck
Junior Member
**
Offline


Posts: 11
Joined: Aug 19th, 2018
Intellisense goes haywire when adding ".c" file
Jun 21st, 2022 at 10:40pm
Print Post  
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.
  

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


Posts: 11
Joined: Aug 19th, 2018
Re: Intellisense goes haywire when adding ".c" file
Reply #1 - Jun 21st, 2022 at 10:42pm
Print Post  
Here it is before I add the ".c" file.
  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Intellisense goes haywire when adding ".c" file
Reply #2 - Jun 21st, 2022 at 11:38pm
Print Post  
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?
« Last Edit: Jun 21st, 2022 at 11:41pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline


Posts: 11
Joined: Aug 19th, 2018
Re: Intellisense goes haywire when adding ".c" file
Reply #3 - Jun 22nd, 2022 at 1:52am
Print Post  
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: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Intellisense goes haywire when adding ".c" file
Reply #4 - Jun 22nd, 2022 at 11:44pm
Print Post  
We will look into it thanks
  
Back to top
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline


Posts: 11
Joined: Aug 19th, 2018
Re: Intellisense goes haywire when adding ".c" file
Reply #5 - Jun 22nd, 2022 at 11:56pm
Print Post  
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: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Intellisense goes haywire when adding ".c" file
Reply #6 - Jun 23rd, 2022 at 1:08am
Print Post  
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
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline


Posts: 11
Joined: Aug 19th, 2018
Re: Intellisense goes haywire when adding ".c" file
Reply #7 - Jun 23rd, 2022 at 5:00pm
Print Post  
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
« Last Edit: Jun 23rd, 2022 at 5:01pm by DisplayNamesSuck »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Intellisense goes haywire when adding ".c" file
Reply #8 - Jun 24th, 2022 at 5:50pm
Print Post  
  
Back to top
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline


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

  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Intellisense goes haywire when adding ".c" file
Reply #10 - Jun 24th, 2022 at 10:06pm
Print Post  
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
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline


Posts: 11
Joined: Aug 19th, 2018
Re: Intellisense goes haywire when adding ".c" file
Reply #11 - Jun 24th, 2022 at 11:17pm
Print Post  
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
  

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


Posts: 11
Joined: Aug 19th, 2018
Re: Intellisense goes haywire when adding ".c" file
Reply #12 - Jun 25th, 2022 at 12:46am
Print Post  
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.
  

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Intellisense goes haywire when adding ".c" file
Reply #13 - Jun 26th, 2022 at 8:09pm
Print Post  
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.
« Last Edit: Jun 26th, 2022 at 8:13pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
DisplayNamesSuck
Junior Member
**
Offline


Posts: 11
Joined: Aug 19th, 2018
Re: Intellisense goes haywire when adding ".c" file
Reply #14 - Jun 27th, 2022 at 2:45am
Print Post  
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: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Intellisense goes haywire when adding ".c" file
Reply #15 - Jun 27th, 2022 at 1:38pm
Print Post  
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.
« Last Edit: Jun 27th, 2022 at 1:39pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Intellisense goes haywire when adding ".c" file
Reply #16 - Jun 29th, 2022 at 12:47am
Print Post  
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.

  

Please Register or Login to the Forum to see File Attachments
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint