Re: Compiler error when using typedef void as function parameter with gcc 4.4.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 9 Feb 2023 at 14:08, Singh, Mithun via Gcc-help
<gcc-help@xxxxxxxxxxx> 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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux