Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #102448
| Message-Id | <53illd-6q4.ln1@walter.foo> |
|---|---|
| From | "Peter \"Shaggy\" Haywood" <phaywood@alphalink.com.au> |
| Subject | Re: Valid struct cast? |
| Newsgroups | comp.lang.c |
| Date | 2017-01-25 14:19 +1100 |
| References | <2d4012cb-cb2a-4d18-9339-d3a51cb5fef2@googlegroups.com> |
Please forgive the lateness of this followup.
Groovy hepcat Thiago Adams was jivin' in comp.lang.c on Fri, 13 Jan 2017
10:28 pm. It's a cool scene! Dig it.
> Is it safe to cast from 'FromArray' to 'ToArray'?
>
> typedef struct
> {
> Type1** pItems;
> int size;
> int capacity;
> } FromArray;
>
>
> typedef struct
> {
> void** pItems;
> int size;
> int capacity;
> } ToArray;
In short, no.
Actually, it is not allowed. A cast operator can only be applied to
scalar (integer, floating and pointer) types, unless the resulting type
is void. You can't cast a struct to another struct.
Chapter & verse:
6.5.4 Cast operators
...
Constraints
2 Unless the type name specifies a void type, the type name shall specify
atomic, qualified, or unqualified scalar type, and the operand shall have
scalar type.
--
----- Dig the NEW and IMPROVED news sig!! -----
-------------- Shaggy was here! ---------------
Ain't I'm a dawg!!
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
Valid struct cast? Thiago Adams <thiago.adams@gmail.com> - 2017-01-13 03:28 -0800
Re: Valid struct cast? BartC <bc@freeuk.com> - 2017-01-13 12:12 +0000
Re: Valid struct cast? Thiago Adams <thiago.adams@gmail.com> - 2017-01-13 04:29 -0800
Re: Valid struct cast? Barry Schwarz <schwarzb@dqel.com> - 2017-01-13 08:11 -0800
Re: Valid struct cast? supercat@casperkitty.com - 2017-01-13 09:09 -0800
Re: Valid struct cast? Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-14 01:01 -0800
Re: Valid struct cast? "Peter \"Shaggy\" Haywood" <phaywood@alphalink.com.au> - 2017-01-25 14:19 +1100
csiph-web