Getting some compiler/ lint errors for this code. Don’t get what they mean,
Does not work
int main(void)
{
int CountRating();
return 0;
}
ERRORS:
--- Module:
int CountRating();
c(70): warning 937: (Note -- old-style function declaration for function 'CountRating')
.c(70): warning 580: (Warning -- Redeclaration of function 'CountRating(void)' (hiding line 25) causes loss of prototype)
}
C1A5E1_CountRating.c(73): warning 752: (Info -- local declarator 'CountRating()' (line 70) not referenced)
--- Global Wrap-up
(70): warning 714: (Info -- Symbol 'CountRating(void)' (line 70, file c) not referenced)
Works:
int main(void)
{
CountRating();
return 0;
}
What do I have to do to make it return an int?
means you are declaring a function prototype. it can be done within function but should be avoided. (Not a best practice). You are getting warnings because prototype doesn’t match the actual function
(int CountRating()vsint CountRating(void).means you are calling this function from another method and it is perfectly allowed. hence no warnings.
if you want to get the returnrd value from function, do it as following: