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
Very Hot Topic (More than 25 Replies) std::function... shows red waved line (Read 13784 times)
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
std::function... shows red waved line
Jan 21st, 2018 at 12:50pm
Print Post  
Hi,

what do I have to do that intellisense accepts this code:
Code (C++)
Select All
typedef std::function<void()> SimpleHandlerFunction;
typedef std::function<void(String fileName)> FileNameHandlerFunction 



VS2015 shows red waved lines (s. attachment)


I'm using this versions
Microsoft Visual Studio Community 2015, Version 14.0.25431.01 Update 3
Microsoft .NET Framework, Version 4.7.02556
VM 1.1711.19
ESP8266 V. 2.4.0
« Last Edit: Jan 21st, 2018 at 12:51pm by Red Baron »  

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: std::function... shows red waved line
Reply #1 - Jan 21st, 2018 at 2:53pm
Print Post  
You add project wide "intellisense redefines" as a workaround to VS C++/GCC incompatibilities but we can also investigate a better solution. 

This article shows how to redefine intellisense without adding to normal code or breaking compile.

http://www.visualmicro.com/page/Extending-Visual-Studio-Intellisense.aspx

  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #2 - Jan 22nd, 2018 at 1:30pm
Print Post  
Thanks for hint.

I have another project with the same content. There the identical lines are shown correctly with no red wave lines (see attachment). The includes are the same too. Therefore project specific defines are not a good solution. It seems that there is a hidden problem with VM. Intellisense shows this message: "Der qualifizierte Name ist nicht zulässig" (English translation: "The qualified name is not allowed"). In similar cases I get then message: "namespace 'std' has no member 'function'". 

It seems that "#include <functional>" is not scanned by intellisence 

I tried "Rescan Toolchain and Libraries" and "Toggle Hidden Files": no effect. I deleted project folders ".vs", "_vm", "release" and opened VS again to rebuild these folders: no effect.

I tried "Debug" and "Release" configuration: no differece. I compared the project properties: no difference.

I deleted windows temp folder to clean the build: no effect.


May be the difference depends on how the project was created. The file that shows the error is an include file from a Arduino library. The library has an example included. When creatig the project via "VM explorer -> Examples -> Open Copy" the copy shows the error. 
Then I created a new project with VS "File -> new -> Arduino project". I copied the files from library's example folder manually to the new project folder and inculded them to the project. In this case everything looks fine. 

There might be a different project structure depending on the project creation type
  

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: std::function... shows red waved line
Reply #3 - Jan 22nd, 2018 at 3:37pm
Print Post  
Can you zip and email both projects to info[at]visualmicro.com

We use standard vs c++ projects so the difference will be in the vs project properties.   

It is true that when you use file>new>project we use the standard vs c++ project wizard to create a project. When using "file>new>arduino project" we clone an existing vcxproj that is installed with the software. (This is because microsoft have an issue on some vs ide's where the new c++ project template is corrupted)

There both vcxproj files are c++ but it sounds like there is a difference in the VC++ tools specified in the .vcxproj files.








  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #4 - Jan 22nd, 2018 at 4:14pm
Print Post  
ok, mail ist sent
  
Back to top
 
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #5 - Jan 23rd, 2018 at 9:31am
Print Post  
Hi,

when you make a copy of a library example you should copy folder "data" too.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #6 - Jan 27th, 2018 at 3:57pm
Print Post  
In the next release sub folders are now included in the library cloning process. The clone system was created before sub folders were supported so thanks for the tip.

I have looked at your two projects. In the explorer project created via the library clone you have included the arduino core and library sources using the visual micro src\_micro-api-readonly short cuts. You should delete the _micro-api-readonly folder and then reopen vs to be sure we have a clean comparison.

Thanks
  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #7 - Jan 27th, 2018 at 7:54pm
Print Post  
I'm sorry, but i really don't know what you want me to do.

For me the problem is solved. I now know the cause of the problem and have a workarround. I very rarely use library examples. And if I need to use one of the examples I will do it with a clean project. So for me everything is fine.

If you want me to support you, I will gladly do it. 
I never did anaything with "_micro-api-readonly". What I did was:
1. Make a copy clone of a library example that includes "<functional>" in one of the files: gives red waved lines but compiles without error.
2. Setup a clean project with a copy of the example files. There are no red waved lines. Compiles without errors to.

If you want, I can try to create a most simple project that shows the problem.
  
Back to top
 
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #8 - Jan 27th, 2018 at 8:13pm
Print Post  
I just took an fresh copy for the exmaple and examined the folder with the Explorer. I didt not found anything like "_micro-api-readonly".

But there is another intellisense problem:

The porject uses a project spefic class (e.g. "Settings") that is derived from a library class (e.g. "SettingsBase"). In the .ino file there is an include to "settings.h". seetings.h" has an inlude to "SettingsBase.h". The .ino file has no include to "SettingsBase.h".

If you access one of the base class methods (e.g. "SettingsBase::loadFromFile(...)") they are marked as an error (waved red line). "Rescan Toolchain and Libraries" does not help. After compiling the waved lines disappear. 

May be, its the same as above. But there is a difference: this error mark disappears after compiling, the above does not.
« Last Edit: Jan 27th, 2018 at 8:15pm by Red Baron »  

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: std::function... shows red waved line
Reply #9 - Jan 27th, 2018 at 8:17pm
Print Post  
Did you try to close and reopen the project. When a project opens all of the includes are reset, as they are when you add a lib or make other changes. I suspect the issue is that after cloning an example the intellisense is not being updated straight away.

Switching to a different board and back again also forces an intellisense refresh.

Can you try that please?

I can look at individual intellisense errors more easily with the initial issue solved.

Thanks
  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #10 - Jan 27th, 2018 at 9:19pm
Print Post  
Switching the board solves the problem. You have to switch to a board with a different architecture. Switching from one ESP8226 board (e.g. "Wemos D1 mini" to "NodeMCU") has no effect. When switching to an AVR board and back solves the problem.

I'm still using VS 2015 Community. Is there a better intellisence support in VS 2017? If so, I would switch to that version. C(++) is not my favorite programming language. So intellisense is a great help for me.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #11 - Jan 28th, 2018 at 3:16am
Print Post  
Great I will look why the intelli refresh isn't being kicked off automatically after a clone/create. Thanks

Q: Does building also cause the refresh to happen?

As for VS IDE benefits you have to take your chances but know that I have them all installed and run them side-by-side. Projects are compatible so you can try them as you please.

The visual micro install is per ide but the single license activation covers them all at the same time.

VS2017 install of visual micro will happen after you close the IDE. The installer is really clunky.
« Last Edit: Jan 28th, 2018 at 3:17am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #12 - Jan 28th, 2018 at 8:35am
Print Post  
Tim@Visual Micro wrote on Jan 28th, 2018 at 3:16am:

Q: Does building also cause the refresh to happen?


Yes, it does.
  
Back to top
 
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #13 - Apr 28th, 2018 at 7:52am
Print Post  
Hi,

there is still a problem with intellisense and include file "functional".

In "functional" macros like "_GLIBCXX_..." are used. These are defined in 
ig.h"

It seems that the corresponding directory is not scanned. 
0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\"  is available. 

But 
0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\xtensa-lx106-elf\bits" is not.



The program is compiling without errors.

I tried to add this directory to the projects properties, but no success. VM deletes this entry.

I'm using
VM: 1.1803.26
VS: Microsoft Visual Studio Community 2015, Version 14.0.25431.01 Update 3
ESP 2.4.1

Was the upload of attachments turned off? I wolud like to add a screenshot, but found no option to to this.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #14 - Apr 28th, 2018 at 12:37pm
Print Post  
It's okay for me so some questions:-

1)
please say which board and if possible provide simple sample code/project

2)
does this happen in new projects as well as your current project?
« Last Edit: Apr 28th, 2018 at 12:45pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #15 - Apr 28th, 2018 at 3:00pm
Print Post  
I'm using board: WeMos D1 R2 & mini

I created a new project, copied all sources from the existing project to the new one, included them to the project and added the necessary libraries to the new project. Looks fine now without any error markers. It compiles without any problems.

I closed the project and reopened it: is still alright.
I changed the board to one with another architcture and back: still ok!


Thanks for the hint. I will create a new project frame for the relevant old ones.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #16 - Apr 28th, 2018 at 3:20pm
Print Post  
Oh, useful thanks.

Q:

In your original project, if you change board to a different toolchain such as arduino uno then back to wemos does that cause intellisense rescan and issue to be resolved?

« Last Edit: Apr 28th, 2018 at 3:21pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #17 - Apr 28th, 2018 at 3:29pm
Print Post  
No, this is what I tried first. In former times some of these problems disappeared after changing board to another architecture and back. Sometimes compiling solved the problem.

But in the current version is didn't help.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #18 - Apr 28th, 2018 at 4:14pm
Print Post  
Okay thanks. if you can email the .vcxproj file to info[at]visualmicro.com that would help thanks
  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #19 - Apr 28th, 2018 at 4:40pm
Print Post  
Now I know the reason for the problem! 

I moved the project to the "myExamples" folder. The project file ".vcxproj" contains relative paths like "$(ProjectDir)..\libraries\UrsWiFi\src;" or <ClInclude 1\cores\esp8266\Arduino.h" />

They are relative to the project folder. After moving these paths are invalid. I copied the project back to the original place and the error markers disappear.

I mostly actived "toggle hidden files". At the new place clicking at a library file gives an error: "can't open file". Clicking "toggle hidden files" twice does a rescan and after this you can open the files. But standard include files do not seem to be taken into account.

Compiling the project never gives an error. There seem to be different search strategies for the different tasks. 

For me I would suggest that "Rescan Toolchains and Libraries" should do the work.


I will send .vcxproj files to the above address.
  
Back to top
 
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #20 - Apr 28th, 2018 at 4:50pm
Print Post  
Another fact: compiling works with absolute paths like  -I"C:\Users\Ulli\Documents\Arduino\libraries\UrsWiFi\src"
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #21 - Apr 28th, 2018 at 9:36pm
Print Post  
Thanks for sending the files.

Yes, the intellisense is just standard vs c++ with some overrides that visual micro forces, the compile is handled by visual micro. Visual studio doesn't know about some of the underlying gcc code. Hopefully visual studio will become easier to extend languages in without huge development work.

The re-scan tool chains just re-reads the hardware and board info and is unrelated to any projects

The refresh of each projects intellisense, if it has changed, is supposed to happen automatically when major events happen such as build, saving changed code, change board etc.

Each projects can only have one set of intellisense paths.

If you have a project where the intellisense is wrong, then change to another board then the intrellisense should change for that board. If it does and then you switch back to the original (broken) board, if the intellisense does not correct itself then it might be the vs intellisense database is corrupt. In that case close the solution and delete the .vs folder from where the solution exists.
  
Back to top
WWW  
IP Logged
 
Red Baron
Member
***
Offline


Posts: 106
Location: Germany
Joined: Jul 29th, 2015
Re: std::function... shows red waved line
Reply #22 - Apr 30th, 2018 at 9:13am
Print Post  
Today, I switched to VS 2017. That solved the problem.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #23 - Apr 30th, 2018 at 12:55pm
Print Post  
Thanks for the note. I will re-test VS2015 but 2017 is probably better going forward.
  
Back to top
WWW  
IP Logged
 
ceepee
Newbies
*
Offline


Posts: 3
Joined: Mar 6th, 2020
Re: std::function... shows red waved line
Reply #24 - Mar 6th, 2020 at 3:55pm
Print Post  
Sorry for the necro, but I still have this problem with VS2019. I tried rebuilding, adding "#include <functional>" (and several others), deleting the __vm folder, changing board types (and archs), creating a new project with the same files, adding "-std=gnu++11" to the cpp flags.

I'm at a loss here. I cannot get the intellisense to work with std::function. Compiling works like a charm though. 

(And by the way: A huge thanks for this great plugin!)

edit#1: Added screenshot of intellisense error popup.

edit#2: I saw the referenced "functional" file in External Dependencies is "..\libraries\ArduinoSTL\src\functional" which indeed does not define the std::function I want to use. I guess it should be a506\xtensa-lx106-elf\include\c++\4.8.2\functional"?
« Last Edit: Mar 6th, 2020 at 4:30pm by ceepee »  

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: std::function... shows red waved line
Reply #25 - Mar 7th, 2020 at 11:19pm
Print Post  
We will shortly add intellisense paths using a more intelligent system. If you can proe what paths are needed for the version of esp you are using we can add them.

Add a local board.txt to the project manually or using the vMicro "Add Code" menu. Add a property called vm.intellisense.add-paths= with a semi-colon list of additional paths, hard code or use any build variable. For example...

Code
Select All
-elf\include\c++\4.8.2\functional 



Then click build, then see if intellisense is improved. 

« Last Edit: Mar 7th, 2020 at 11:59pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
ceepee
Newbies
*
Offline


Posts: 3
Joined: Mar 6th, 2020
Re: std::function... shows red waved line
Reply #26 - Mar 8th, 2020 at 5:44pm
Print Post  
That helps indeed, thanks!

Would it make sense to to just add the whole folder like this?
Code
Select All
-elf\include\c++\4.8.2 



Anyway, glad to hear you're working on improving irritiating intellisense stuff like this, even if it's just a minor annoyance Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #27 - Mar 8th, 2020 at 5:46pm
Print Post  
It might well do. Can you give it a try?
  
Back to top
WWW  
IP Logged
 
ceepee
Newbies
*
Offline


Posts: 3
Joined: Mar 6th, 2020
Re: std::function... shows red waved line
Reply #28 - Mar 8th, 2020 at 5:50pm
Print Post  
Oh yeah sorry, forgot to mention it works. I was not sure if I might shoot myself in the foot with it in some other way though.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: std::function... shows red waved line
Reply #29 - Mar 8th, 2020 at 5:51pm
Print Post  
That's useful thanks but I was hoping that you would be able to answer the latter part of your last statement  Smiley
« Last Edit: Mar 8th, 2020 at 5:51pm 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: std::function... shows red waved line
Reply #30 - Mar 8th, 2020 at 6:17pm
Print Post  
I look at this and it was actually an oversight. The path for the older tool chain was supposed to be in the intellisense list already. If you had been using recent esp32 toolchains they come with 5.2.0 which is catered for.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: [1] 
Send TopicPrint