linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* strange gcc warning
@ 2003-01-13 17:57 Shanks
  2003-01-13 18:26 ` Steven Smith
  2003-01-13 19:25 ` Elias Athanasopoulos
  0 siblings, 2 replies; 7+ messages in thread
From: Shanks @ 2003-01-13 17:57 UTC (permalink / raw)
  To: linux-c-programming

Hi,

Sample program: b.c
#include <stdio.h>
#include <errno.h>

void
my_print(int errno)
{
    printf("ERRNO: %d\n", errno);
}

int
main()
{
    int a = 10;
    errno = 0;
    my_print(a);
}

On compiling this code i get the warning:
b.c: In function `main':
b.c:15: warning: passing arg 1 of `my_print' makes pointer from integer without
a cast

On running the code i get a seg. fault. So i did some gdb'ing and got
(gdb) run 
Starting program: ./b
Breakpoint 1, my_print (__errno_location=0x19) <<<<<<<<
    at b.c, line...
(gdb)

From above i see that instead of getting a plain int its go the address.
But i would like it if someone explained it to me better.

Thanks in advance.
-S

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: strange gcc warning
@ 2003-01-14  7:01 Govind Raghuram
  0 siblings, 0 replies; 7+ messages in thread
From: Govind Raghuram @ 2003-01-14  7:01 UTC (permalink / raw)
  To: Shanks; +Cc: Elias Athanasopoulos, linux-c-programming



Your definition will remain local as long as you dont include errno.h



                                              Placed At :


Shanks <mshanks79@yahoo.co.in> on 01/13/2003 11:37:50 PM

To:   Elias Athanasopoulos <eathan@otenet.gr>
cc:   linux-c-programming@vger.kernel.org (bcc: Govind Raghuram/Satyam)

Subject:  Re: strange gcc warning




--- Elias Athanasopoulos <eathan@otenet.gr> 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)

> Elias
-Shanks

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming"
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html






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

end of thread, other threads:[~2003-01-14  7:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
2003-01-14  7:01 Govind Raghuram

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).