When are function prototypes necessary?

When are function prototypes required when programming the arduino?

I have never had to declare function prototypes for the arduino. However, the code below does require the following prototoype:

void gpsdump(TinyGPS &gps);

In the thread at the following link, it states that the compiler will generate function prototypes automatically.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1288542862

Here’s example code for compiling. Comment out “void gpsdump(TinyuGPS &gps)” to see my issue.

#include <TinyGPS.h>

TinyGPS gps;

void gpsdump(TinyGPS &gps);
bool feedgps();

void setup()
{
      Serial.begin(115200);
      Serial1.begin(4800);
}

void loop()
{
      bool newdata = false;
      unsigned long start = millis();

      // Every 5 seconds we print an update
      while (millis() - start < 5000)
      {
            if (feedgps())
            newdata = true;
      }

      if (newdata)
      {
            Serial.println("Acquired Data");
            Serial.println("-------------");
            gpsdump(gps);
            Serial.println("-------------");
            Serial.println();
      }
}

void gpsdump(TinyGPS &gps)
{
      long lat, lon;
      float flat, flon;
      unsigned long age, date, time, chars;
      int year;
      byte month, day, hour, minute, second, hundredths;
      unsigned short sentences, failed;

      gps.get_position(&lat, &lon, &age);
      Serial.print("Lat/Long(10^-5 deg): "); Serial.print(lat); Serial.print(", "); Serial.print(lon); 
      Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");

      feedgps(); // If we don't feed the gps during this long routine, we may drop characters and get checksum errors

      gps.f_get_position(&flat, &flon, &age);
      Serial.print("Lat/Long(float): "); Serial.print(flat, 5); Serial.print(", ");Serial.print(flon, 5);
      Serial.print(" Fix age: "); Serial.print(age); Serial.println("ms.");
}

bool feedgps()
{
      while (Serial1.available())
      {
            if (gps.encode(Serial1.read()))
            return true;
      }
      return false;
}

The only case I'm aware of that you need to generate a function prototype is when the function takes a reference argument (preceded by the &).

Older versions of Arduino required that functions with reference parameters had to be defined or declared before they are used in a sketch.

With arduino-0022, I can comment out both function prototypes and your sketch compiles without errors.

Regards,

Dave

OK, now I understand. I have never used pointers and I am using version 21. Problem solved. Thanks for the help.