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
Tip: Don't declare classes in .pde/.ino (Read 2409 times)
CapnBry
Junior Member
**
Offline



Posts: 32
Tip: Don't declare classes in .pde/.ino
Nov 4th, 2011 at 3:13pm
 
I've got a PDE file that declares a class in it that compiles fine under Arduino but not in Visual Micro. Turns out the pde preprocessor doen't like classes inside .pde files because it adds forward declarations for class members. Take this example.pde

Code:
class A
{
public:
 virtual void foo() {}
};

void setup()
{
}

void loop()
{
}
 



This fails to compile with "virtual outside class declaration" because what is actually compiled adds a "virtual void foo();" above the class declaration. I'll submit this to codeplex but it is a gotcha that can emit any number of strange compiler errors, depending on what methods you have in your class. It confused the heck out of me because my class was actually a recursive template class definition which emitted a plethora of errors.

The solution is to define your classes in either a .h or .cpp file, which isn't preprocessed to add forward declarations.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10463
United Kingdom
Re: Tip: Don't declare classes in .pde/.ino
Reply #1 - Nov 4th, 2011 at 3:24pm
 
Thanks very much, we have had one other strange preprocessor report but the user failed to provide the code when asked.

This really helps, I guess it is the same issue. I'll have to look at the regex that is used to get the prototypes. It was originally copied from the arduino source so either we messed it up which is difficult to do or .net works slightly differntly to java.

Yes codeplex issue would be great thanks
Back to top
 
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print