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 Absolute unexplainable errors (Read 2472 times)
Kabron
Full Member
***
Offline


Posts: 170
Joined: Nov 1st, 2015
Absolute unexplainable errors
Jul 14th, 2018 at 11:29am
Print Post  
Board ODROID-GO (almost M5STACK clone)
example Tetris from https://github.com/hardkernel/ODROID-GO
All SW components up-to-date.
Arduino IDE compilation - no problem.

VM Compilation errors:
Tetris.ino: 15:17: error: 'Block' was not declared in this scope
   int screen[Width][Height] = {0}; \\it shows color-numbers of all positions
 
Tetris.ino: 15:30: error: 'Point' was not declared in this scope
   int screen[Width][Height] = {0}; \\it shows color-numbers of all positions
 
Tetris.ino: 15:41: error: expected primary-expression before 'int
   int screen[Width][Height] = {0}; \\it shows color-numbers of all positions
 
Tetris.ino: 15:50: error: 'Point' was not declared in this scope
   int screen[Width][Height] = {0}; \\it shows color-numbers of all positions
Error compiling project sources
Build failed for project 'Tetris'
« Last Edit: Jul 14th, 2018 at 11:31am by Kabron »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Absolute unexplainable errors
Reply #1 - Jul 14th, 2018 at 12:46pm
Print Post  
Hi,

Something relatively new in the arduino world is ability for auto protoype of functions with user types. The arduino solution is a step in the right direction but still prone to issue which arduino will improve sometime. Until then, in Visual Micro, you need to add your own prototypes for functions that use "user types" as shown below. This only applies to .ino code, in .cpp code you would always need to create prototypes in both arduino ide and visual micro.


Examples. It's easier when you post that you post link to your code or the example you have used for your code. The link you posted to a library is not so useful. For compile errors it is also useful to switch on the verbose option on the vmicro menu and also useful to enable "show build properties". With these options ON you can then submit the build output with your reports so that you do not need to bother explaining which ide, board and tool chain you are using.

In this case I guessed the project code you are using is this code?


In the code you can see GetSquares is passed a user type called Block which is created earlier in the same .ino code. In this case we can simply add a prototype as follows. Notice a prototype is simply the same as the method signature but ending with ; and containing no code....

Code
Select All
bool GetSquares(Block block, Point pos, int rot, Point* squares);

//========================================================================
bool GetSquares(Block block, Point pos, int rot, Point* squares) {
   //code here
} 




In your Tetris code there are only three methods that use "user types", therefore inserting the prototypes between where the user types are created and where the functions are located is quite easy. keep in mind this is standard c++ so we are not making something that will break with other compilers.

Code
Select All
bool GetSquares(Block block, Point pos, int rot, Point* squares);
void GetNextPosRot(Point* pnext_pos, int* pnext_rot);
void ReviseScreen(Point next_pos, int next_rot);
 


« Last Edit: Jul 14th, 2018 at 12:50pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Kabron
Full Member
***
Offline


Posts: 170
Joined: Nov 1st, 2015
Re: Absolute unexplainable errors
Reply #2 - Jul 14th, 2018 at 1:00pm
Print Post  
Thanks a lot,
Tim@Visual Micro wrote on Jul 14th, 2018 at 12:46pm:
It's easier when you post that you post link to your code or the example you have used for your code.

As usual the examples folder is in the ODROID-GO library folder:
\Arduino-ESP32-IDE\Proj\libraries\ODROID-GO\examples\Applications\Tetris\

I do not fully understand how to redeclare
struct Point {int X, Y;};
and
struct Block {Point square[4][4]; int numRotate, color;};
« Last Edit: Jul 14th, 2018 at 1:07pm by Kabron »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Absolute unexplainable errors
Reply #3 - Jul 14th, 2018 at 1:02pm
Print Post  
Oh thanks. I forgot that examples can have sub folders and can now see the Tetris.ino thanks.

For other readers it is clearer if I show what the user types are and the order that code should follow. 

In this case Point and Block is defined in the .ino code as follows. The c++ prototypes must  be inserted between the definition and the functions that use the types...


//definition of types
Code
Select All
struct Point {int X, Y;};
struct Block {Point square[4][4]; int numRotate, color;}; 




//prototypes for functions that use the types
Code
Select All
void myFunc(Point p, Block b); 




//functions that use the types
Code
Select All
void myFunc(Point p, Block b)
{

} 





« Last Edit: Jul 14th, 2018 at 1:06pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Kabron
Full Member
***
Offline


Posts: 170
Joined: Nov 1st, 2015
Re: Absolute unexplainable errors
Reply #4 - Jul 14th, 2018 at 1:14pm
Print Post  
Well, in other words after creating structures I have to revise which functions uses it and put declaration of these functions after structures declaration at the beginning of the code.

In my case it looks like:
struct Point {int X, Y;};
struct Block {Point square[4][4]; int numRotate, color;};

....

....

bool GetSquares(Block block, Point pos, int rot, Point* squares);
void GetNextPosRot(Point* pnext_pos, int* pnext_rot);
void ReviseScreen(Point next_pos, int next_rot);

...
void setup()
... etc

Now it works. Thanks again.
« Last Edit: Jul 14th, 2018 at 1:18pm by Kabron »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Absolute unexplainable errors
Reply #5 - Jul 14th, 2018 at 1:37pm
Print Post  
That's right. 

tip: If you have vMicro > General > Tutorial Mode enabled and use File>New>Arduino>Project then the comments in the new code should show this too.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint