public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Compiler error when using typedef void as function parameter with gcc 4.4.2
@ 2023-02-09 14:07 Singh, Mithun
  2023-02-09 14:27 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Singh, Mithun @ 2023-02-09 14:07 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]

Hello,

I have typedef void as follows in one of my header files:

typedef void VOID;

And I am using this typedef as function parameter as follows:

VOID  someFunction(VOID);

This code compiles fine with gcc 3.3.5, but when I compile it with gcc 4.4.2, I get following error:

error: '<anonymous>' has incomplete type
error: invalid use of 'VOID'

Will you please shed some light on why would it not work with gcc 4.4.2?

Thanks,
Mithun

This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original. Neither this information block, the typed name of the sender, nor anything else in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Compiler error when using typedef void as function parameter with gcc 4.4.2
  2023-02-09 14:07 Compiler error when using typedef void as function parameter with gcc 4.4.2 Singh, Mithun
@ 2023-02-09 14:27 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2023-02-09 14:27 UTC (permalink / raw)
  To: Singh, Mithun; +Cc: gcc-help

On Thu, 9 Feb 2023 at 14:08, Singh, Mithun via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> Hello,
>
> I have typedef void as follows in one of my header files:
>
> typedef void VOID;
>
> And I am using this typedef as function parameter as follows:
>
> VOID  someFunction(VOID);

Why would you want to do that? It's just silly.

> This code compiles fine with gcc 3.3.5, but when I compile it with gcc 4.4.2, I get following error:

Why are you using such ancient versions? It's not 2009.

>
> error: '<anonymous>' has incomplete type
> error: invalid use of 'VOID'
>
> Will you please shed some light on why would it not work with gcc 4.4.2?

Because the C++ standard says it's not valid, and GCC got fixed to
follow the standard. A function with no parameters can only be
declared with () or (void), not with a typedef to void. The tokens
"(void)" have special meaning for compatibility with C, but (VOID) is
nonsense.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=9278

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-09 14:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 14:07 Compiler error when using typedef void as function parameter with gcc 4.4.2 Singh, Mithun
2023-02-09 14:27 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).