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


Groups > comp.lang.c > #77996

Re: Question about type cast in queue code

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Question about type cast in queue code
Date 2015-12-06 12:28 -0800
Organization None to speak of
Message-ID <lnd1ujpbi5.fsf@kst-u.example.com> (permalink)
References (1 earlier) <n1ggg3$ag8$1@dont-email.me> <8c81e1b0-cd60-44a9-8d48-21b266a97ce9@googlegroups.com> <n1h3lu$6t1$1@dont-email.me> <MPG.30a71fd29d392c1b84@news.eternal-september.org> <d3c86bhci7p71v54e9ujpnq7cvt9f2k81g@4ax.com>

Show all headers | View raw


David Thompson <dave.thompson2@verizon.net> writes:
> On Fri, 6 Nov 2015 20:37:10 -0800, Philip Lantz <prl@canterey.us>
> wrote:
[...]
>> struct Queue_Elem;
>> 
>> int main()
>> {
>>     Queue_Elem *elem = 0;
>>     void *myQ = 0;
>> 
>>     elem != (Queue_Elem *)myQ;
>> 
>>     return 0;
>> }
>> 
> As long as we're nitpicking, in C you need something like 
>
> typedef struct new_tag_name Queue_Elem;
> /* new_tag_name MAY be Queue_Elem but need not */

No, you don't *need* a typedef.  You can just refer to the type by
its original name, which happens to be `struct Queue_Elem`.  Using a
typedef to give it a new name `Queue_Elem` is entirely optional.

> In C++ a tag works almost like a typedef. Not C.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Question about type cast in queue code fl <rxjwg98@gmail.com> - 2015-11-05 12:21 -0800
  Re: Question about type cast in queue code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-05 20:43 +0000
  Re: Question about type cast in queue code James Kuyper <jameskuyper@verizon.net> - 2015-11-05 16:10 -0500
    Re: Question about type cast in queue code fl <rxjwg98@gmail.com> - 2015-11-05 16:50 -0800
      Re: Question about type cast in queue code James Kuyper <jameskuyper@verizon.net> - 2015-11-05 21:37 -0500
        Re: Question about type cast in queue code Philip Lantz <prl@canterey.us> - 2015-11-06 20:37 -0800
          Re: Question about type cast in queue code James Kuyper <jameskuyper@verizon.net> - 2015-11-07 00:20 -0500
            Re: Question about type cast in queue code Philip Lantz <prl@canterey.us> - 2015-11-07 11:51 -0800
              Re: Question about type cast in queue code James Kuyper <jameskuyper@verizon.net> - 2015-11-07 15:34 -0500
                Re: Question about type cast in queue code Philip Lantz <prl@canterey.us> - 2015-11-07 13:42 -0800
                Re: Question about type cast in queue code James Kuyper <jameskuyper@verizon.net> - 2015-11-07 16:53 -0500
          Re: Question about type cast in queue code David Thompson <dave.thompson2@verizon.net> - 2015-12-06 07:56 -0500
            Re: Question about type cast in queue code Keith Thompson <kst-u@mib.org> - 2015-12-06 12:28 -0800
              Re: Question about type cast in queue code Philip Lantz <prl@canterey.us> - 2015-12-06 13:29 -0800
        Re: Question about type cast in queue code James Kuyper <jameskuyper@verizon.net> - 2015-12-06 18:18 -0500
          Re: Question about type cast in queue code supercat@casperkitty.com - 2015-12-06 15:31 -0800

csiph-web