Hay i got it wrong variable name
sorry :(

-
-- In [email protected], "Brett McCoy" <[EMAIL PROTECTED]> wrote:
>
> On 10/4/07, sadhanavs <[EMAIL PROTECTED]> wrote:
> 
> >  I have two files extern_function.c and extern_file.c.
> >
> > // extern_file.c
> >
> >   int x =20;
> >   int getData()
> >   {
> >    return 20;
> >   }
> >
> > // extern_function.c
> >
> > extern int getValue();
> > extern int k;
> > int main()
> > {
> >
> >  printf("%d\n", getValue());
> >  getInput();
> >  return 0;
> >
> > }
> >
> > int getInput(){
> >    printf(" Value:-%d ",k);
> >    return 0;
> > }
> 
> 
> I don't see anywhere where you define k. You declare it with extern
> which means the compiler is expecting it to be defined somewhere 
else.
> Did you mean int k = 20 in the first file?
> 
> > i compile it using gcc.
> >
> > gcc extern_file.c extern_function.c
> > Undefined                       first referenced
> >  symbol                             in file
> > k                                   /var/tmp//ccctm19K.o
> > ld: fatal: Symbol referencing errors. No output written to a.out
> > collect2: ld returned 1 exit status
> >
> > Why is that the function getValue() works with extern and not k?
> > I commented out the printf("%d",k);
> > Is there something else i need in order to get the object files 
linked?
> >
> > Thanks
> > Sadhana
> >
> >
> >
> > To unsubscribe, send a blank message to <mailto:c-prog-
[EMAIL PROTECTED]>.
> > Yahoo! Groups Links
> >
> >
> >
> >
> 
> 
> -- 
> ------------------------------------------------------------
> "In the rhythm of music a secret is hidden;
>     If I were to divulge it, it would overturn the world."
>                -- Jelaleddin Rumi
>


Reply via email to