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 error: 'b' was not declared in this scope (Read 2289 times)
iain frew
Junior Member
**
Offline


Posts: 11
Joined: Nov 17th, 2017
error: 'b' was not declared in this scope
May 4th, 2018 at 7:14pm
Print Post  
Code compiles in Arduino but gives error in Visual studio. Using Ardunio 1.8.5, Vmicro version 1711.19.0

testbug.ino: 5:11: error: variable or field 'test' declared void
   void test(b bstruct)
 
Error compiling project sources
testbug.ino: 5:11: error: 'b' was not declared in this scope
Build failed for project 'testbug'

Any ideas? code is below.

struct a {
     int number;
};

struct b {
     a astruct;
};


void test(b bstruct) {

};

void setup(){

};

void loop(){

};

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: error: 'b' was not declared in this scope
Reply #1 - May 4th, 2018 at 7:53pm
Print Post  
if you add the prototype yourself then using your own types in the same file (as opposed to .h) is more controllable.

In background, arduino ide will add prototypes before the first function, visual micro before first code. Both can be wrong depending on the code, so it's safer to add your own like this...

Code (C++)
Select All

//types
//
struct a {
     int number;
};

struct b {
     a astruct;
};

// add a method prototype with the same signature; after types have been created but before the actual method
//
void test(b bstruct);


//code
//
void test(b bstruct) {

};

void setup(){

};

void loop(){

};

 

« Last Edit: May 4th, 2018 at 7:57pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
iain frew
Junior Member
**
Offline


Posts: 11
Joined: Nov 17th, 2017
Re: error: 'b' was not declared in this scope
Reply #2 - May 4th, 2018 at 8:02pm
Print Post  
Thanks for that info!!! Could not figure it out at all. yip it compiles now.

Many thanks
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint