Quote Originally Posted by Alterah View Post
If for some reason the header file is not included in the file that we call the function, can C and the linker still somehow find the definition for this function and compile and link fine?
It will compile and link "fine", as far as 'C' is concerned. That's the problem.

If you don't tell 'C' about the functions you're calling by prototyping them, nothing can coerce the compiler to do anything except assume the function returns an int. Without a prototype, you can put all sorts of code that suggests that the function returns a double or float, but that isn't going to help you. For 'C', you must tell the 'C' compiler up front the exact prototype of your functions.

Yes, the linker will find the function, and that again becomes a problem. The original simple program I posted without the header produces undefined behaviour. Since the sin() function actually returns a double, but the compiler assumes it returns an int, who knows what condition the stack will be on return. Maybe the stack is so messed up, the program may crash.
Edit: That appears to be what happened. I never actually checked this file to see if it included the header file with the prototype. Our build system wound up finding the object with the function definition and linked that. After including the correct header file, everything appears to be working. Thank you Paul. You've been a huge help. I've also learned something about C I never knew.
No problem.

Regards,

Paul McKenzie