Switch off Arduino Automatic Prototype Generation

by Visual Micro 5. June 2013 07:59

It is possible to turn off automatic prototype generation in Visual Micro by setting the project property called "Auto Generate Prototypes=False".

The following code will not compile with Arduino or the default Visual Micro, because the function prototype for doLogic() would be automatically 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.

Code:


typedef enum {RANDOM, IMMEDIATE, SEARCH} StrategyType;

void doLogic(StrategyType s)
{
//code
}

void loop()
{
doLogic(RANDOM);
doLogic(IMMEDIATE);
doLogic(SEARCH);
}


Extract via capnBry in the forum