This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Should compiler generate an error at the time of compiler?


On Wed, 2004-09-22 at 22:00, Sergey M. Samoylov wrote:
> I have a code with mistake:
> 
> extern int errno;
> main()
> {
> 	printf("errno=%d",errno);
> }
> Why in any cross gcc compilers when it compiler, compiler will pass?
> Why compiler will not say me about any mistakes like:
> : undefined reference to 'errno'
> 
> It's just only in cross compiler in usuall compiler gcc-3.3.1 it's OK and 
> compiler generate the error.

There is no actual error here.  you are defining an external variable
that is errno that may or may not exist at link time.  I have a bit of
legacy code and the link step fails not the compile step.

If the cross compiler defines errno as a true external int (which is
permissible under the standard) but of course it is not portable.

-- 
Thanks
KenF
OpenOffice.org developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]