public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: "Singh, Mithun" <mithun.singh@wabtec.com>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: Compiler error when using typedef void as function parameter with gcc 4.4.2
Date: Thu, 9 Feb 2023 14:27:18 +0000	[thread overview]
Message-ID: <CAH6eHdRXUF-AHjJGWUNSvROik=n9CEZ+wenrRZWWMxHKFsVi7Q@mail.gmail.com> (raw)
In-Reply-To: <DS7PR07MB83501B0D1C14FBB409C2166BE5D99@DS7PR07MB8350.namprd07.prod.outlook.com>

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

      reply	other threads:[~2023-02-09 14:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 14:07 Singh, Mithun
2023-02-09 14:27 ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH6eHdRXUF-AHjJGWUNSvROik=n9CEZ+wenrRZWWMxHKFsVi7Q@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=mithun.singh@wabtec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).