I have a rather large program that is divided into multiple source code files, and compiled using a Makefile. I'm having problems passing arguments to functions that are in other source code files. The called function seems to ignore the values that are passed in. Indeed it doesn't even care if the right number of arguments are passed in at all.
The following code should illustrate my problem:
first file: main.c
second file: sub.c
int write_arg(float x)
fprintf(stdout,"value passed in is %g\n",x);
If I move the function write_arg in the same file as main(), then the program correctly fails to compile, because it is being called with too many arguments. But if I put write_arg in a separate file, as I did here, then the program compiles and runs successfully, and I get this output:
CC = /usr/bin/gcc
test: main.c sub.c
$(CC) -o test main.c sub.c
value passed in is 0
In other words, all of the (too many) values that I passed in were ignored. Can anyone explain to me why?
Thanks in advance.