Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
Visual Micro >> Installation & Troubleshooting >> A lot of errors 'was not declared in this scope'
https://www.visualmicro.com/forums/YaBB.pl?num=1567978291

Message started by Vosreinard on Sep 8th, 2019 at 10:31pm

Title: A lot of errors 'was not declared in this scope'
Post by Vosreinard on Sep 8th, 2019 at 10:31pm
Hi,
In my Rotary Table Project I use two sets .cpp & header files: Wstepper and Wcld.
I get errors in Wstepper.cpp an Wcld.cpp saying about a lot of variables, included over ARDUINO.h, that they are not declared.
What can be mitigated?

https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=RotaryTable_001.zip (3065 KB | 5 )

Title: Re: A lot of errors 'was not declared in this scope'
Post by Simon Hopkinson on Sep 9th, 2019 at 10:35am
Ensure the include paths for your header files includes the relative path, like below:

#include "src/Wlcd/Wlcd.h"
#include "src/Wstepper/Wstepper.h"

This should resolve the initial errors, and this also detailed on the below page:
https://www.visualmicro.com/page/Understanding-Project-File-Structure.aspx

Title: Re: A lot of errors 'was not declared in this scope'
Post by Vosreinard on Sep 9th, 2019 at 1:24pm
Dear Simon,
Thanks for your reply. Helas :-[, when applying #include "src/Wcld/Wcld.h" instead of #include "Wlcd.h" the program will be thrown back to the situation I had before I posted my previous question "Source file cannot find header file" with answer from Tom Leek. https://www.visualmicro.com/forums/YaBB.pl?num=1567802164/1#1 .
The problem is as follows: EEPROM.h can be found but not the underlaying functions, etcetera.
again: What can be done to resolve those problems?
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=output_09-09-2019.txt (58 KB | 3 )

Title: Re: A lot of errors 'was not declared in this scope'
Post by Visual Micro on Sep 9th, 2019 at 1:44pm
If you click the little icon "show all files" above the solution explorer you can see physical files on disk. Then you will see that you have not included the src sources codes in your project.

Right click them and click "Include in project", then the red warning indicator will be removed.
files-must-be-included-in-project.png (10 KB | 2 )

Title: Re: A lot of errors 'was not declared in this scope'
Post by Vosreinard on Sep 9th, 2019 at 4:19pm
Thanks for reply.
I already has included those files before sending the built log.
Something else must be playing with the devil.


https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=output_2019-09-09-2nd.txt (58 KB | 3 )
Aantekening_2019-09-09_164202.png (15 KB | 2 )

Title: Re: A lot of errors 'was not declared in this scope'
Post by Visual Micro on Sep 9th, 2019 at 4:56pm
Have you #include <Arduino.h> in your .cpp code?

Visual Micro and the Arduino IDE only automatically add the #include for .ino code.

Title: Re: A lot of errors 'was not declared in this scope'
Post by Vosreinard on Sep 9th, 2019 at 7:29pm
https://www.visualmicro.com/public_html/yabbfiles/Smilies/dankk2.gif Yes I did without a positive result.https://www.visualmicro.com/public_html/yabbfiles/Templates/Forum/default/cry.gif
In Solutions Explorer I have included RotaryTable.log . Maybe this will be useful.
[edit]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018: The "VCMessage" task failed unexpectedly.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at System.String.Format(IFormatProvider provider, String format, Object[] args)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at Microsoft.Build.Shared.ResourceUtilities.FormatString(String unformatted, Object[] args)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.FormatString(String unformatted, Object[] args)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(String resourceName, Object[] args)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.LogErrorWithCodeFromResources(String messageResourceName, Object[] messageArgs)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at Microsoft.Build.CPPTasks.VCMessage.Execute()
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(379,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
[/edit]


regards

Title: Re: A lot of errors 'was not declared in this scope'
Post by Visual Micro on Sep 10th, 2019 at 12:34pm
Thise errrors are visual studio trying to make a build and idicates some unexpected errors. Visual Micro has given up trying to compile or things that it does not have too.

I just compiled your project okay but I had to add

#include <Arduino.h>

and change
#include <Wstepper.h>

to
#include "Wstepper.h"

I notice you have used a couple of arduino from the web. You should not try to compile arduino libraries from within your project code most are not designed for that.

You should make your project work in the arduino ide so you can understand how arduino works. Then if you want local library sources you can use the options on the Add Library menu in visual micro which will create a local copy.

The ideal would be

SolutionFolder
      Libraries
         Library1
      Projects
          Project1

But intiially place libraries in mydocument\arduino\libraries because both visual micro and arduino will consider that valid.

The error you have posted is from the visual studio output window when set to build. Visual Micro adds Micro Build output window with its own reporting.

tip: If the project name, project folder name and an .ino name are all the same then visual micro will consider the project an arduino project and manage it for you.

Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2019. All Rights Reserved.