linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* function cast?
@ 2010-01-28  6:05 Randi Botse
  2010-01-28  6:09 ` Randi Botse
  0 siblings, 1 reply; 4+ messages in thread
From: Randi Botse @ 2010-01-28  6:05 UTC (permalink / raw)
  To: linux-c-programming

Hi All,

Sometimes i see codes are written like this:

(void) printf(fmt);

- or -

(void) close(fd);

What these means? i think it is not necessary to put that 'void' on a
statement, or it just like when we cast a data type? so the email

Thanks,

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

* function cast?
  2010-01-28  6:05 function cast? Randi Botse
@ 2010-01-28  6:09 ` Randi Botse
  2010-01-28  6:20   ` Manish Katiyar
  0 siblings, 1 reply; 4+ messages in thread
From: Randi Botse @ 2010-01-28  6:09 UTC (permalink / raw)
  To: linux-c-programming

(sorry for my first uncomplete email, please abandon the first mail)

Hi All,

Sometimes i see codes are written like this:

(void) printf(fmt);

- or -

(void) close(fd);

What these means? i think it is not necessary to put that 'void' on a
statement, or it just like when we cast a data type like:

double d = 93.43;
int i = (int) d;

but why those function need to be casted in a 'void' ?

Thanks,

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

* Re: function cast?
  2010-01-28  6:09 ` Randi Botse
@ 2010-01-28  6:20   ` Manish Katiyar
  2010-02-01  4:33     ` phil song
  0 siblings, 1 reply; 4+ messages in thread
From: Manish Katiyar @ 2010-01-28  6:20 UTC (permalink / raw)
  To: Randi Botse; +Cc: linux-c-programming

On Thu, Jan 28, 2010 at 11:39 AM, Randi Botse <nightdecoder@gmail.com> wrote:
> (sorry for my first uncomplete email, please abandon the first mail)
>
> Hi All,
>
> Sometimes i see codes are written like this:
>
> (void) printf(fmt);
>
> - or -
>
> (void) close(fd);
>
> What these means? i think it is not necessary to put that 'void' on a
> statement, or it just like when we cast a data type like:
>
> double d = 93.43;
> int i = (int) d;
>
> but why those function need to be casted in a 'void' ?

Some time it is also to shut up static analysis tools, which might
crib if the function is supposed to return a value and you have not
used the return value. It might be intentional or you might have just
missed. So inorder to show that it is intetional not to use the return
value we typecast it.

Thanks -
Manish

>
> Thanks,
> --
> 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
>



-- 
Thanks -
Manish
==================================
[$\*.^ -- I miss being one of them
==================================
--
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] 4+ messages in thread

* Re: Re: function cast?
  2010-01-28  6:20   ` Manish Katiyar
@ 2010-02-01  4:33     ` phil song
  0 siblings, 0 replies; 4+ messages in thread
From: phil song @ 2010-02-01  4:33 UTC (permalink / raw)
  To: Manish Katiyar, Randi Botse; +Cc: linux-c-programming

HI,Manish Katiyar!

	thanks,I see too now.

======= 2010-01-28 14:24:58 The letter which you writted before:=======

>On Thu, Jan 28, 2010 at 11:39 AM, Randi Botse <nightdecoder@gmail.com> wrote:
>> (sorry for my first uncomplete email, please abandon the first mail)
>>
>> Hi All,
>>
>> Sometimes i see codes are written like this:
>>
>> (void) printf(fmt);
>>
>> - or -
>>
>> (void) close(fd);
>>
>> What these means? i think it is not necessary to put that 'void' on a
>> statement, or it just like when we cast a data type like:
>>
>> double d = 93.43;
>> int i = (int) d;
>>
>> but why those function need to be casted in a 'void' ?
>
>Some time it is also to shut up static analysis tools, which might
>crib if the function is supposed to return a value and you have not
>used the return value. It might be intentional or you might have just
>missed. So inorder to show that it is intetional not to use the return
>value we typecast it.
>
>Thanks -
>Manish
>
>>
>> Thanks,
>> --
>> 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
>>
>
>
>
>-- 
>Thanks -
>Manish
>==================================
>[$\*.^ -- I miss being one of them
>==================================
>--
>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

= = = = = = = = = = = = = = = = = = = =
			

Sincerely
 
phil song
philsong@techtrex.com
2010-02-01

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

end of thread, other threads:[~2010-02-01  4:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-28  6:05 function cast? Randi Botse
2010-01-28  6:09 ` Randi Botse
2010-01-28  6:20   ` Manish Katiyar
2010-02-01  4:33     ` phil song

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