VS Arduino
>> >> Toggle auto-generating function prototypes
https://www.visualmicro.com/forums/YaBB.pl?num=1367805803

Message started by EhNon on May 6th, 2013 at 2:03am

Title: Toggle auto-generating function prototypes
Post by EhNon on May 6th, 2013 at 2:03am
So yeah, because all the function prototypes are created automatically you can't pass or return typedef'd stuff. So it would be cool to be able to turn it off. (They don't exist yet, when the auto-generated prototype is created).

Title: Re: Toggle auto-generating function prototypes
Post by Visual Micro on May 6th, 2013 at 3:20am
Good idea for advanced users. In the next release this is implemented as a project property:-


Quote:
Category="Micro General (Project Global)"

Description="Auto generation of prototypes for sketch source code. The default is True for Arduino projects. This property is for advanced users.

Name="Generate Prototypes"

It might also be useful to have some sort of //<no-proto/> comment that could be used to skip individual prototypes. Would this be useful? If so then we can add it to the list for a version later this year.

Thanks for the suggestion

Title: Re: Toggle auto-generating function prototypes
Post by Visual Micro on May 9th, 2013 at 8:39pm
This feature is implemented in the latest download. Thanks.

Note to others: If you switch off auto generation of prototypes your project will loose compatibility with the Arduino Ide because compilation will fail

Title: Re: Toggle auto-generating function prototypes
Post by CapnBry on Jun 5th, 2013 at 1:37pm
Sweet! This is especially useful for anyone trying to use enumerated types in their sketch:
[code]
typedef enum {RANDOM, IMMEDIATE, SEARCH} StrategyType;

void doLogic(StrategyType s)
{
//code
}

void loop()
{
  doLogic(RANDOM);
  doLogic(IMMEDIATE);
  doLogic(SEARCH);
}
[/code]
This code won't compile under Arduino or default Visual Micro thanks to the function prototype for doLogic() being inserted before the enum definition. The only way around this previously was to define your enum in a header which you then included in the main sketch, which is annoying if you want to keep everything all tidy in one file.

If you turn off prototype generation, zing! Works great.

Title: Re: Toggle auto-generating function prototypes
Post by Visual Micro on Jun 5th, 2013 at 2:59pm
Thanks for confirming the feature works and for the example, I will add it to the wiki.

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.