Going through your book and enjoying the straight-forward methodology but wondering about the suggestion to disable the missing function prototypes warning. Is this normal practice or should we actually be defining the prototype in the header file?
Well, here’s the thing: For this tiny program there is no header file. So, you’d need to create a header file, add a declaration to it, and then #import it into the main.c file. That seemed like an awful lot of work to avoid a rather pedantic warning.
Or, you could just put the function prototype at the top of the .c file, ala:
[code]float remainingAngle(float angleOne, float angleTwo);
float remainingAngle(float angleOne, float angleTwo)
return 180.0 - (angleOne + angleTwo);
int main(int argc, const char * argv)
float angleA = 30.0;
float angleB = 60.0;
float angleC = remainingAngle(angleA, angleB);
printf("The third angle is %.2f\n", angleC); return 0;
But doing that kinda/sorta defeats the whole purpose of doing this in .h files, I think, which is to expose the structure without exposing the code, right? Or to be able to distribute libraries in binary form but still document the calling format?