Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #16412

Re: typecast function pointer

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: typecast function pointer
Date 2012-01-29 14:27 -0800
Organization None to speak of
Message-ID <lnk44aywia.fsf@nuthaus.mib.org> (permalink)
References <jg0sdr$b96$1@speranza.aioe.org> <jg0ui5$o9l$1@dont-email.me> <jg4epn$se9$1@speranza.aioe.org>

Show all headers | View raw


"Mark" <mark_cruzNOTFORSPAM@hotmail.com> writes:
> "Eric Sosman" <esosman@ieee-dot-org.invalid> wrote in message 
> news:jg0ui5$o9l$1@dont-email.me...
>>     No, because `int' and `s_int32_t' are *not* different types.
>> A typedef declaration does not create a new type; it just creates
>> an additional name for an existing type.  Also, `signed int' and
>> `int' are not different types, but just two different ways to
>> name the same type.  All of `s_int32_t', `signed int', and `int'
>> are different ways of naming one type, and all three aliases can
>> be used interchangeably.[*],[**]
>
> Thanks for comprehensive answers!
>
> What can be the reason to declare a function returning 'signed int' instead 
> of 'int' if those are all the same types? IMHO it only brings in confusion, 
> as in my case.

The compiler doesn't care whether you write "int", or "signed int", or
"signed", or "int unsigned" for that matter.

You might write "signed int" for emphasis, to distinguish it from
"unsigned int":

    unsigned int this_function(void);
    signed int   that_function(void);

(And "signed int" is not necessarily "int" when used to declare a bit
field, but the question was about function return types, so that doesn't
apply.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
    Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

typecast function pointer "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2012-01-28 08:15 -0500
  Re: typecast function pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-28 08:52 -0500
    Re: typecast function pointer "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2012-01-29 16:47 -0500
      Re: typecast function pointer Ian Collins <ian-news@hotmail.com> - 2012-01-30 10:56 +1300
      Re: typecast function pointer Keith Thompson <kst-u@mib.org> - 2012-01-29 14:27 -0800
        Re: typecast function pointer Ike Naar <ike@iceland.freeshell.org> - 2012-01-30 00:14 +0000
          Re: typecast function pointer Keith Thompson <kst-u@mib.org> - 2012-01-29 21:05 -0800
      Re: typecast function pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-29 18:07 -0500
        Re: typecast function pointer Keith Thompson <kst-u@mib.org> - 2012-01-29 21:06 -0800
  Re: typecast function pointer Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-28 14:08 +0000

csiph-web