This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Should compiler generate an error at the time of compiler?
- From: Ken Foskey <foskey at optushome dot com dot au>
- To: ssamoylov at dev dot rtsoft dot ru
- Cc: gcc help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 22 Sep 2004 21:58:28 +1000
- Subject: Re: Should compiler generate an error at the time of compiler?
- References: <200409221600.31034.ssamoylov@dev.rtsoft.ru>
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