From: Elias Athanasopoulos <eathan@otenet.gr>
Cc: xlp <xlp@emtel.net.co>,
linux-c-programming@vger.kernel.org, jason@txt.com
Subject: Re: [jason@txt.com: Re: Problem with "chars"]
Date: Wed, 17 Jul 2002 21:16:39 +0300 [thread overview]
Message-ID: <20020717211639.L1163@neutrino.particles.org> (raw)
In-Reply-To: <200207171755.g6HHtsF0004688@grinch.txt.com>; from jason@txt.com on Wed, Jul 17, 2002 at 10:55:52AM -0700
On Wed, Jul 17, 2002 at 10:55:52AM -0700, Jason P. Winters wrote:
> Huh? I mean, excuse me? Where do you find a reference to _not_ casting
> the output of malloc()? Malloc returns a (void *) reference, you -need-
> to cast it to the type you're assigning it as.
>
> If you don't cast it, you get a warning message:
>
> tst.c: In function `foo':
> tst.c:17: warning: assignment makes pointer from integer without a cast
>
>
> So, do we ignore the message from the compiler?
>
> Now, *That's* a bad habit to get into...
Pls, include stdlib.h and you'll be happy.
The C standard (call it C99, but this comes from the earlier days) states
that void * is implicitly casted to everything is on the other side.
By explicitly casting malloc() you don't get the warning you wrote, but
the correct way to vanish the warning is to include stdlib.h.
Elias
--
http://gnewtellium.sourceforge.net MP3 is not a crime.
next prev parent reply other threads:[~2002-07-17 18:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-17 14:33 [jason@txt.com: Re: Problem with "chars"] xlp
2002-07-17 17:55 ` Elias Athanasopoulos
2002-07-17 17:55 ` Jason P. Winters
2002-07-17 18:07 ` Glynn Clements
2002-07-17 18:24 ` Jason P. Winters
2002-07-17 18:54 ` Glynn Clements
2002-07-17 18:16 ` Elias Athanasopoulos [this message]
2002-07-17 19:30 ` Marius Nita
2002-07-18 14:43 ` Earl R. Lapus
2002-07-24 19:56 ` Mike Castle
2002-07-24 21:05 ` Jason P. Winters
2002-07-24 22:38 ` Glynn Clements
-- strict thread matches above, loose matches on Subject: below --
2002-07-18 7:11 Alvarez Alberto-AALVARB1
2002-07-18 9:25 ` Elias Athanasopoulos
2002-07-18 9:18 ` Marius Nita
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=20020717211639.L1163@neutrino.particles.org \
--to=eathan@otenet.gr \
--cc=jason@txt.com \
--cc=linux-c-programming@vger.kernel.org \
--cc=xlp@emtel.net.co \
/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).