public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* modifying gcc files and getting error
@ 2009-12-17  9:33 Wei Li
  2009-12-17  9:48 ` John Graham
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Li @ 2009-12-17  9:33 UTC (permalink / raw)
  To: gcc-help

Dear all:

I am trying to change some source files in the GCC compiler and
getting a compilation error.

In the file "gimple.h", I am adding

extern int  x; // the x is global and  should be accesable from other
files as well.


Then I called x in the "tree_into_ssa.c". However, when I compile the
gcc compiler using the make command I get the following massage:

undefined refernce to "x".


Any comments???

Thanks,
Abid



-- 
Regards,

Wei Li

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: modifying gcc files and getting error
  2009-12-17  9:33 modifying gcc files and getting error Wei Li
@ 2009-12-17  9:48 ` John Graham
  0 siblings, 0 replies; 2+ messages in thread
From: John Graham @ 2009-12-17  9:48 UTC (permalink / raw)
  To: gcc-help

> I am trying to change some source files in the GCC compiler and
> getting a compilation error.
>
> In the file "gimple.h", I am adding
>
> extern int  x; // the x is global and  should be accesable from other
> files as well.
>
>
> Then I called x in the "tree_into_ssa.c". However, when I compile the
> gcc compiler using the make command I get the following massage:
>
> undefined refernce to "x".
>
>
> Any comments???

First, this is really a general programming question, and this mailing
list is more for gcc-specific issues. In future, try a general
programming forum like at
http://www.linuxquestions.org/questions/programming-9/.

This error occurs because "extern int x" declares a variable called x,
but does not define it - you need to define it (exactly once) with
"int x" in a source file that will be linked in with whatever source
files you want to use it in. If you don't know the difference between
declaring and defining a variable, I suggest you get a good C book and
have a thorough read.

John G

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-12-17  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-17  9:33 modifying gcc files and getting error Wei Li
2009-12-17  9:48 ` John Graham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).