On 2026-01-06 07:32, Michael Sanders wrote:
On Mon, 5 Jan 2026 08:39:53 -0000 (UTC), Michael Sanders wrote:
I might have questions down the road...
In the message you were responding to, I was talking about declarations,
not expressions.
One more question, but 1st the context...
I asked ChatGPT this question:
In C, what is the most common meaning of (void) *foo
I'm curious - in what context did you encounter that code? As written,
it's an expression, and foo would have to be a pointer to an object,
which would be a change of subject from the previous messages in this
thread.
However,
(void) *foo;
would be a declaration equivalent to
void *foo;
which is a pointer to void, which would fit the context of our previous discussion. Could that be what you're actually asking about?
However,
(void) *foo;
would be a declaration equivalent to
void *foo;
which is a pointer to void, which would fit the context of our previous discussion. Could that be what you're actually asking about?
On Tue 1/6/2026 7:58 AM, James Kuyper wrote:
However,
ÿÿÿÿÿ (void) *foo;
would be a declaration equivalent to
ÿÿÿÿ void *foo;
which is a pointer to void, which would fit the context of our previous
discussion. Could that be what you're actually asking about?
Um... I believe Tim Rentsch is correct in stating that C declaration
syntax does not allow this. When it comes to 'declaration-specifiers' portion of the declaration, the grammar is pretty strict in not allowing
and redundant parentheses to slip through. You can't simply parenthesize
the type name and still expect it to match the 'declaration-specifiers' grammar.
The 'init-declarator-list' side is way more permissive in that regard
ÿ int (a); /* equivalent to `int a;` */
but not what you stated above.
P.S. On a loosely related note: the C++-like grammatical ambiguity
between a function call and a declaration, present in
ÿ { foo(x); }
is technically present in C as well, but it is prevented by the fact
that there's simply no way to declare `foo` as a function and as a
typedef name without having one name hide another.
On Tue 1/6/2026 7:58 AM, James Kuyper wrote:
However,
(void) *foo;
would be a declaration equivalent to
void *foo;
which is a pointer to void, which would fit the context of our previous
discussion. Could that be what you're actually asking about?
Um... I believe Tim Rentsch is correct in stating that C declaration
syntax does not allow this. [...]
| Sysop: | Tetrazocine |
|---|---|
| Location: | Melbourne, VIC, Australia |
| Users: | 15 |
| Nodes: | 8 (0 / 8) |
| Uptime: | 84:44:44 |
| Calls: | 208 |
| Files: | 21,502 |
| Messages: | 81,377 |