Go Down

Topic: Problem with automatic prototype generation in the Arduino IDE (Read 687 times) previous topic - next topic

EbiDK

Feb 23, 2012, 01:15 pm Last Edit: Feb 23, 2012, 01:19 pm by EbiDK Reason: 1
As discussed in http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1195036223/15 the way the automatic prototype generation works causes some issues(http://www.arduino.cc/en/Guide/Troubleshooting#toc22).

One suggestion for a workaround to implement that was not suggested there but should be fairly easy to do is to check if an exact prototype for the function that was just encountered has already been seen, if not then make one as usual. If it has been seen(because it was already written in the source) then don't generate a prototype. Update the FAQ with a comment about explicitly putting in a prototype if you use custom datatypes in the return type or argument list of a function to maybe fix the issue).

Currently it doesn't seem to matter if you explicitly declare prototypes.

The old thread suggests typecasting void pointers which of course works but it much more ugly and less readable than this solution would be, not to mention the horrors that can come of (beginners) playing with pointers.

EbiDK

A patch that fixes some of the problem at least: https://github.com/arduino/Arduino/pull/64.

If you use a custom datatype as a return value or argument of a function, put a prototype for the function somewhere between the datatype definition and the function definition, the IDE will assume you know what you're doing and not generate a prototype for the function itself and just leave the one you defined in place.

Go Up