Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 136303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:55:37+00:00 2026-05-11T06:55:37+00:00

I have the following code: typedef void VOID; int f(void); int g(VOID); which compiles

  • 0

I have the following code:

typedef void VOID; int f(void); int g(VOID); 

which compiles just fine in C (using gcc 4.3.2 on Fedora 10). The same code compiled as C++ gives me the following error:

void.c:3: error: ‘<anonymous>’ has incomplete type void.c:3: error: invalid use of ‘VOID’ 

Now, this is something in external library and I would like the owner to fix that problem. So I have a question – does C++ standard forbids this construct? Could you give me a pointer/citation? The only thing I can recall is that function declaration with (void) to signal empty parameter list is deprecated in C++, but I don’t understand why typedefed VOID does not work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:55:38+00:00Added an answer on May 11, 2026 at 6:55 am

    Yes, as far as i know the second declaration is invalid in C++ and C89, but it is valid in C99.

    From The C99 draft, TC2 (6.7.5.3/10):

    The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters.

    It’s explicitly talking about the type ‘void’, not the keyword.

    From The C++ Standard, 8.3.5/2:

    If the parameter-declaration-clause is empty, the function takes no arguments. The parameter list (void) is equivalent to the empty parameter list.

    That it means the actual keyword with ‘void’, and not the general type ‘void’ can also be seen from one of the cases where template argument deduction fails (14.8.2/2):

    • Attempting to create a function type in which a parameter has a type of void.

    It’s put clear by others, notable in one core language issue report here and some GCC bugreports linked to by other answers.


    To recap, your GCC is right but earlier GCC versions were wrong. Thus that code might have been successfully compiled with it earlier. You should fix your code, so that it uses ‘void’ for both functions, then it will compile also with other compilers (comeau also rejects the second declaration with that ‘VOID’).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 111k
  • Answers 111k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Inline (with or without the literal @"..." syntax) is fine… May 11, 2026 at 9:44 pm
  • Editorial Team
    Editorial Team added an answer Try a Python wrapper for OpenCV such as ctypes-opencv. The… May 11, 2026 at 9:44 pm
  • Editorial Team
    Editorial Team added an answer You can add puts statements to your test case as… May 11, 2026 at 9:44 pm

Related Questions

Can anyone figure out a nice way to get the following code to work?
Given an integer typedef: typedef unsigned int TYPE; or typedef unsigned long TYPE; I
I am reading Microsoft's CRT source code, and I can come up with the
In C++ the following code gives a compiler error: void destruct1 (int * item)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.