This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: help regarding linking
- From: "selvam" <sveeragh at ssd dot usa dot alcatel dot com>
- To: <rganti at nd dot edu>, <gcc-help at gcc dot gnu dot org>
- Date: Sat, 27 Nov 2004 14:31:36 +0530
- Subject: Re: help regarding linking
- References: <1101532467.41a80d3386514@webmail.nd.edu>
Hello Radha Krishna Ganti,
I beleive by including a prototype for the function to_print in
file1.c should solve your problem.
Best Regards,
Selva.
----- Original Message -----
From: <rganti@nd.edu>
To: <gcc-help@gcc.gnu.org>
Sent: Saturday, November 27, 2004 10:44 AM
Subject: help regarding linking
>
> Hi,
> I am a newbie at using gcc. I wanted to write functions and the
main file
> in different files
>
> I am using the following to compile
> gcc -c file1.c
> gcc -c file2.c
> gcc file1.o file2.o
> a.out
> 2.00000 1.90000
>
> I am not able to understand why that is the output. But if write the
> function to_print in file1.c and compile, it works normally.
> If I replace all floats in both files by double it works
>
> What is happening? Am I compiling them wrong.
>
>
> /*----------- file1.c-------------*/
> #include<stdio.h>
> #include<stdlib.h>
>
> int main()
> {
> float a,b;
> a=1.2;
> b=1.3;
> to_print(a,b);
> return 0;
> }
> ---------------file2.c-------------
> #include<stdio.h>
> void to_print(float a, float b)
> {
> printf("%f , %f \n", a,b);
>
> }
>
>
>
> -regards
> Radha Krishna Ganti
>
> --
> Radha Krishna Ganti
> EE-Grad Student
> Univ. Of Notre Dame
>
>