From: Marius Nita <marius@cs.pdx.edu>
To: Shanks <mshanks79@yahoo.co.in>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: strange gcc warning
Date: Mon, 13 Jan 2003 13:35:22 -0800 [thread overview]
Message-ID: <20030113133522.A2782@cs.pdx.edu> (raw)
In-Reply-To: <20030113180750.78660.qmail@web8005.mail.in.yahoo.com>; from mshanks79@yahoo.co.in on Mon, Jan 13, 2003 at 10:07:50AM -0800
On Mon, Jan 13, 2003 at 10:07:50AM -0800, Shanks wrote:
> > On Mon, Jan 13, 2003 at 09:57:55AM -0800, Shanks wrote:
> > > my_print(int errno)
> >
> > errno is defined in errno.h. You shouldn't use a new variable with this
> > name.
> Yes i am aware of errno being defined in errno.h
> But isn't my definition local to my func.
> Any technical reason why i am getting such a gdb output(pasted in prev mail)
Steven Smith already explained everything in detail...
The reason 'locality' doesn't matter here is that errno is a macro. It
actually gets substituted by the preprocessor before the compiler ever
gets the chance to parse your program. It's like saying:
#define foo *bar
int print_foo(int foo) {
printf("%d\n", foo);
}
your function will become
int print_foo(int *bar) {
printf("%d\n", *bar);
}
so saying print_foo(9) is obviously a segfault error: you'll end up
dereferencing address 9, which is most likely not what you want :)
next prev parent reply other threads:[~2003-01-13 21:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-13 17:57 strange gcc warning Shanks
2003-01-13 18:26 ` Steven Smith
2003-01-14 6:00 ` Shanks
2003-01-13 19:25 ` Elias Athanasopoulos
2003-01-13 18:07 ` Shanks
2003-01-13 21:35 ` Marius Nita [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-01-14 7:01 Govind Raghuram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030113133522.A2782@cs.pdx.edu \
--to=marius@cs.pdx.edu \
--cc=linux-c-programming@vger.kernel.org \
--cc=mshanks79@yahoo.co.in \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).