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
Normal Topic Difficulty with VS recognizing identifers? (Read 1194 times)
PoutinePlatter
Junior Member
**
Offline


Posts: 23
Joined: Jun 16th, 2019
Difficulty with VS recognizing identifers?
Jun 16th, 2019 at 9:20pm
Print Post  
VS2017 Community 15.9.13
ArduinoIDE 10.80.9
VM 1906.16.01
Target Teensy 3.6

So after getting single .ino file projects to to compile and load w VM/VS, I wanted to try to do something more "realistic", (I am eval'ing VM/VS to see if we want to move our teams projects over to it) and created a project with:

  • One master sketch file w/ the usual setup() and loop() - call it foo_project_Teensy.ino - in the name-matching folder
  • Added a matched set of .h / .c files - call them foo_this_that.h & foo_this_that.c - using the "Add Code" menu choice 


Problem is - the .c and .h have random issues with identifiers / tags being recognized.  
not recognized: bool, uint8_t, uint16_t, class... others
recognized fine: lots of things - uint32_t, typdef, struct, extern, actual typedef'd names... 

This causes a massive pile of Intellisense warnings and errors, most of which are completely false but make it impossible to weed out the 'good' stuff (actual coding errors). Oddly in Solution Explorer the .c file doesn't get a 'c' icon, or a '++' icon, just a 'blank page' icon. includes are not working in those files for sure 

I have tried:
  • Recreating it with File-New-ArduinoProject (then copying contents back in)
  • Recreating it with vMicro-NewArduinoProject (same)
  • Reinstalling ArduinoIDE & Teensyduino
  • Searching high and low for some file or config setting or naming issue or typo


With no luck.   Undecided

I'm guessing I've just made some dumb mistake but really can't find it.  Directions to look would be as always greatly appreciated!?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Difficulty with VS recognizing identifers?
Reply #1 - Jun 16th, 2019 at 9:32pm
Print Post  
Hi,

We just use standard visual studio c++ projects to give us intellisense and code editor. Therefore you can create/add files using any method you want. If you use the standard "add new item" and add a .c file I assume you see the wrong icon too? If so then maybe you vs needs a repair.

It would help to have a sample project that shows this issue. I have installed the latest teensy and selected the "arduino 1.6/18" app to use it without issue.

The vs intellisense does struggle at times with certain gcc syntax but I wouldn't expect an issue with basic types! Did you make a build of the new project? building does add extra intellisense support. Microsoft are slowly releasing a new intellisense system based on clang which will be better for gcc.

Did you mean to create a .c file or a .cpp?

Are you seeing these errors in your own code or in he Errors List window? If just in the error window then set it to "open documents" or "build only". The underlying teensy system code is not great for the vs intellisense engine but might have improved in vs2019.

Please follow the guide in yellow at the top of this page to give your full config so that it can be reviewed.

Thanks
« Last Edit: Jun 16th, 2019 at 9:36pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Difficulty with VS recognizing identifers?
Reply #2 - Jun 16th, 2019 at 9:54pm
Print Post  
I tried this again but this time looked for errors in the Errors List. I could see nearly 2000 in VS2017 and 1500 in VS2019. All the false errors related to the underlying core not my own project code.

I then click "vMicro>Show Hidden Files" which is recommended for better F12 GoTo Definition anyway. Then the error list reduced to 3 errors without need to filter the Error List for "Open Documents" or "Build Only".

  
Back to top
WWW  
IP Logged
 
PoutinePlatter
Junior Member
**
Offline


Posts: 23
Joined: Jun 16th, 2019
Re: Difficulty with VS recognizing identifers?
Reply #3 - Jun 17th, 2019 at 12:41pm
Print Post  
OK.  I have this mostly figured out. 

It's a .c/.cpp thing.  Though oddly the problems flow to the header file too. 

I'm calling FlexCAN lib which is C++.  But I'm using (temporarily - fully intend to convert to OO/C++ ASAP... ) ported C code, so I added a .h and .c file. 

Of course (duh moment when I realized this) the compiler (and Intellisense) can't use the FlexCAN classes in the .c file. Very obvious dumb mistake by me on that end. 

Whats less obvious is that it breaks IS parsing vastly beyond just error-ing on the ++ extension keywords and syntax.  It blows up the header file too (which I find odd.. as I'd think the header file would be non-denominational).  Clearly there's some hard coding of matching-named header files with source files in the parsing and checking.  I wonder if I named the header file I_don't_match_source_file.h and the C file I_don't_match_header.c if it would work better (which is to say confine my errors to the .c file...).  

But beyond the header it isn't just C++ keywords like "class"... bool doesn't work, and, furthermore, it will cause erratic problems even with the parsing of the master .ino file - its like the presence of the .c file at all forces all files to be parsed as .c only, or 'sometimes' parsed as C. Though that doesn't explain totally the loss of 'bool' and 'uint8_h' keywords/identifiers which naturally should be fine (why is uint8_h busted but uint32_h not?)  

Another symptom is sometimes includes even in the INO are not recognized either as you move between the files back and forth... The behaviour is odd and erratic, sometimes the include-related code lines break and sometimes they look fine.  An example would be declaration of an Adafruit_SSD1306 display aka:

Code (C++)
Select All
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS); 



Sometimes looks fine, other times, broken/errored/acts as if there is no include. 

I have made 2 simplified code projects I will email as above.  One total screwed up w/ .c and the other (almost) fine w/ a .cpp instead. 

I still have a wee problem with collect2.exe and multiple declaration, clearly a result of var initilization in the header.  Thats' just a dumb porting error vs the legacy code structure copy pasted which I can fix easily.  The oldskool code nazi contingent on StackOverflow would probably be enraged at me for even thinking to init the vars in a header file anyway  Wink
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint