Whenever I try to compile my code for this function my compiler keeps throwing

projectB.c:31:15: error: conflicting types for ‘returnDegree’
projectB.c:19:17: note: previous implicit declaration of ‘returnDegree’ was here

#include <stdio.h>
#include<math.h>
int main(){

double sanantonioLat;

sanantonioLat = returnDegree(29.0,25.0,51.0);

printf("blah %f\n" , sanantonioLat);
 

return 0;

}
static double returnDegree(double degree, double minute, double second)
{
double solution;
solution = degree + (minute * (1.0/60.0)) + (second * (1.0/60.0) * (1.0/60.0));
return solution;
}

All of my variables are of type double so why is it complaining about it?
I thought maybe there could be a predefined variable for degree in math.h (below all of this code I've written a very long algorithm for finding the shortest distance between two points on the globe which is why I need the sin, arctan2, etc. from math.h). But I found no such variable.

Please help :) .

You did not declare a prototype for your function. Default would be an int, which doesn't match what the compiler sees, when it gets down to the function.

Put your function prototypes above main(), with the right data types (the actual names of the variables are not needed), just int, char float, double, int *, char *, etc.

The "implicit declaration" is the declaration that the compiler is trying to make work, because you did not an explicit declaration of the function.

Thanks! I always thought prototypes were just for better code readability (optional). It compiles now :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.