Function Return Type Mismatch
semantic
warning: return makes integer from pointer without a cast
Description
Returning a value that doesn't match the function's declared return type.
Common Causes
- Returning a pointer from a function declared to return an int
- Returning a float from a function declared to return an int
- Not returning any value from a non-void function
Example of Error
Error Code
int getGreeting() {
return "Hello, World!";
}
Solution
Change the return value to match the function's return type, or change the function's return type.
Corrected Code
char* getGreeting() {
return "Hello, World!";
}
Additional Tips
- Make sure the function's return type matches what you intend to return
- Use
void
for functions that don't return a value - Be consistent with return types across your codebase