newbie question: function call errors

KatrinaTeller

Member
Joined
Aug 30, 2025
Messages
6
I ran into a "conflicting types" error while writing a simple function. I created the function then called it in my main program as just the function name with a variable. That gave me the error. But when I called it by writing out the full return type and parameter type, it worked fine. I'm guessing I'm missing something about declarations versus calls. Do I need to set up... a prototype before using the function or is there another common reason this error shows up?
 
I ran into a "conflicting types" error while writing a simple function. I created the function then called it in my main program as just the function name with a variable. That gave me the error. But when I called it by writing out the full return type and parameter type, it worked fine. I'm guessing I'm missing something about declarations versus calls. Do I need to set up... a prototype before using the function or is there another common reason this error shows up?
yeah, what you're missing is a function prototype. In C, a compiler reads your code from top to bottom.
When it gets to your main function and sees you calling another function, it needs to know what that function is supposed to return and what kind of data it's expecting.
If you haven't prototyped it yet (by declaring it at the top of your file), the compiler doesn't know what to expect and just makes a guess, which leads to that conflicting types error
 
@KatrinaTeller, @CoolBrad2025 is right that a prototype clears up the compiler's guesswork and another common cause of "conflicting types" is mixing int return defaults with an actual declared return type when the prototype is missing. Did you place your function definition below the main or is it in a separate file without a header? This detail changes whether you need a forward declaration or an include.
 
Yep, good point. If you're working with lots of files, double-check that your headers line up in all your code. Type mismatches between files can cause this error too.
 
Back
Top