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 Can't use user-defined data types as arguments to functions??? (Read 2235 times)
Randy P.
Newbies
*
Offline


Posts: 2
Joined: Jul 10th, 2016
Can't use user-defined data types as arguments to functions???
Jul 10th, 2016 at 4:41pm
Print Post  
The statement "You cannot use user defined data types like your own classes, structs or typedefs as arguments to functions." in an ".ino" file is made on this Visual Micro page:
http://www.visualmicro.com/page/User-Guide.aspx?doc=INOs-and-CPPs.html
But I'm confused.  Why can't I pass a user-defined structure to a function???
Thanks.
Randy
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Can't use user-defined data types as arguments to functions???
Reply #1 - Jul 10th, 2016 at 6:38pm
Print Post  
Hi,

Thanks for the post. We are going to change the docs.

You can use them but you need to create the prototype(s) yourself instead of relying on the automatic system.

Code (C++)
Select All
//1. Define types
struct mytype
{}

//2. Create prototype with the exact same signature as the corresponding method
void test(mytype a);

//3. Method that uses the type
void test(mytype a)
{
}
 



Note about auto-generated prototypes

More recently the Arduino IDe has been updated to insert auto generated prototypes at the correct code location. Over the next month or so Visual Micro will be changed to work the same way but in the meantime you can control the insertion point by adding them yourself.
« Last Edit: Jul 10th, 2016 at 6:39pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Randy P.
Newbies
*
Offline


Posts: 2
Joined: Jul 10th, 2016
Re: Can't use user-defined data types as arguments to functions???
Reply #2 - Jul 10th, 2016 at 8:57pm
Print Post  
Okay, that's a relief!  Thanks for spelling it out for me, and for updating the docs and soon the code Wink

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