Compiler error when using typedef void as function parameter with gcc 4.4.2
Jonathan Wakely
jwakely.gcc@gmail.com
Thu Feb 9 14:27:18 GMT 2023
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
More information about the Gcc-help
mailing list