Ancestors

Toot

Written by stefanct on 2024-08-10 at 16:14

Playing around with #C23 stuff and got surprised by this not working…

void func(void);

typedef typeof(func) func_type;

Since a function name is neither an expression nor a type name, it's not supported as operand to typeof (not sure that's all), fair enough but why? @AaronBallman @thephd

I'd have used it to have the prototypes of a library functions in a header and use the typedef within the "private" .c only. This would avoid the alternative of duplicating the prototype within the typedef.

=> More informations about this toot | More toots from stefanct@chaos.social

Descendants

Written by stefanct on 2024-08-10 at 16:27

@AaronBallman @thephd oh it's even worse, typedef doesnt work with typeof at all AFAICT. or i am stupid. >< *opening the actual standard

=> More informations about this toot | More toots from stefanct@chaos.social

Written by Björkus "No time_t to Die" Dorkus on 2024-08-10 at 19:50

@stefanct @AaronBallman This works across all distributions. I think you need to check your flags.

https://godbolt.org/z/z8YTac4x6

=> More informations about this toot | More toots from thephd@pony.social

Written by stefanct on 2024-08-11 at 14:23

@thephd @AaronBallman it was actually simply too old compilers. since typeof was an extension for so long, I got completely thrown off the rails. gcc supports it as a non-extension only since version 13.1.0*. thank you and sorry for bothering you with nonsense :(

(and my initial assumption that a function name isn't an expression was completely bogus too of course - identifiers are primary-expressions).

=> More informations about this toot | More toots from stefanct@chaos.social

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/112938611296055946
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
269.650892 milliseconds
Gemini-to-HTML Time
0.676596 milliseconds

This content has been proxied by September (ba2dc).