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....
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
A lot of errors 'was not declared in this scope' (Read 181 times)
Vosreinard
Newbies
*
Offline



Posts: 6
A lot of errors 'was not declared in this scope'
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?
Back to top
 

RotaryTable_001.zip (3065 KB | 4 )
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 40
Re: A lot of errors 'was not declared in this scope'
Reply #1 - 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
Back to top
 
 
IP Logged
 
Vosreinard
Newbies
*
Offline



Posts: 6
Re: A lot of errors 'was not declared in this scope'
Reply #2 - Sep 9th, 2019 at 1:24pm
 
Dear Simon,
Thanks for your reply. Helas Embarrassed, 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?
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: A lot of errors 'was not declared in this scope'
Reply #3 - 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.
Back to top
 
WWW  
IP Logged
 
Vosreinard
Newbies
*
Offline



Posts: 6
Re: A lot of errors 'was not declared in this scope'
Reply #4 - 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.

Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: A lot of errors 'was not declared in this scope'
Reply #5 - 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.
Back to top
 
WWW  
IP Logged
 
Vosreinard
Newbies
*
Offline



Posts: 6
Re: A lot of errors 'was not declared in this scope'
Reply #6 - 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.gi...
In Solutions Explorer I have included RotaryTable.log . Maybe this will be useful.
Edited:
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.ITaskExecution
Host.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()


regards
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: A lot of errors 'was not declared in this scope'
Reply #7 - 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.
Back to top
« Last Edit: Sep 10th, 2019 at 12:35pm by Visual Micro »  
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print