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 Bug in function prototype generation (Read 2814 times)
Cristian Bontas
Newbies
*
Offline


Posts: 2
Joined: May 3rd, 2017
Bug in function prototype generation
May 3rd, 2017 at 4:15pm
Print Post  
Hello
When the function prototypes are generated in the ino > cpp preprocessing, return types that are nested types are incorrectly reduced to just the inner type, and compilation fails.
This does not happen in the Arduino IDE, so it's probably not their bug.

How to reproduce:
Create a C.h header, and in it a class:
Code (C++)
Select All
class C
{
public:
    enum E { EA, EB };
};
 



In the .ino file include "C.h" and add a function:
Code (C++)
Select All
C::E f()
{
    return C::EA;
}
 



The compilation will fail with "error: 'E' does not name a type".
Looking in the cpp file generated by preprocessing the ino file, the function prototype is:
Code (C++)
Select All
//
E f();
 


Which fails, since "E" is not a valid type.

An easy workaround is to declare/implement the function in .h/.cpp files. But figuring out the problem is not trivial, since the error message makes no sense - until one inspects the generated code.

Regards
Cristian Bontas
« Last Edit: May 3rd, 2017 at 4:16pm by Cristian Bontas »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Bug in function prototype generation
Reply #1 - May 3rd, 2017 at 4:23pm
Print Post  
Hi,

Thanks for the report. The arduino ide changed how they create prototypes last year. they now use the results of Gcc-E and ctags. Visual Micro will make the same move shortly but it's more complicated because of debugging.

There is a visual micro project property (F4 on the project node) that allows you to switch off "Auto Generate Prototypes" then you can add them yourself.

I hope this helps.
« Last Edit: May 3rd, 2017 at 4:23pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Cristian Bontas
Newbies
*
Offline


Posts: 2
Joined: May 3rd, 2017
Re: Bug in function prototype generation
Reply #2 - May 4th, 2017 at 4:42pm
Print Post  
Hello
Thanks for the very prompt reply.
Didn't notice that property.
Circumventing the issue is easy, the frustrating part is figuring it out the first time Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Bug in function prototype generation
Reply #3 - May 6th, 2017 at 2:28pm
Print Post  
Yes it's going to be a good change.

Tip for other people who are searching for help on this...

One thing that will help with any auto gen compiler diagnostics might be to switch on "vMicro>Compiler>Show build folder". 

This will give a link in the build output that you can CTRL+CLICK. You can then see the actual build code in the temp folder. 

The [project_name].cpp will contain all of the .ino code along with prototypes and arduino.h include. In debug mode there might also be some additional debug commands.

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