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 7168385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:46:11+00:00 2026-05-28T14:46:11+00:00

The C standard states that, for a function definition, if the declarator includes an

  • 0

The C standard states that, for a function definition, if the declarator includes an identifier list, the types of the parameters shall be declared in a following declaration list. Apparently this makes a difference.

extern int max(int a, int b)
{
return a > b ? a : b;
}

extern int max(a, b)
int a, b;
{
return a > b ? a : b;
}

Here int a, b; is the declaration list for the parameters. The
difference between these two definitions is that the first form acts
as a prototype declaration that forces conversion of the arguments of
subsequent calls to the function, whereas the second form does not.

What does this mean for the programmer and does it affect the code the compiler produces?

  • 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. Editorial Team
    Editorial Team
    2026-05-28T14:46:12+00:00Added an answer on May 28, 2026 at 2:46 pm

    It means that in the second case, it’s the responsibility of the caller to ensure that the arguments provided are of the correct type; no implicit conversion will be provided (other than the default argument promotions). From section 6.5.2.2:

    If the expression that denotes the called function has a type that does not include a
    prototype, the integer promotions are performed on each argument.

    …

    If the expression that denotes the called function has a type that does include a prototype, the arguments are implicitly converted, as if by assignment, to the types of the
    corresponding parameters.

    So calling code like this will be ok:

    char   x = 3;
    char   y = 7;
    max(x, y);  // Equivalent to max((int)x, (int)y)
    

    because x and y are promoted to int before being placed on the stack.

    However, code like this will not be ok:

    double x = 3.0;
    long   y = 7;
    max(x, y);  // Uh-oh
    

    x and y will be placed on the stack as double and long, but max() will attempt to read two ints, which will result in undefined behaviour (in practice, the raw bits will be reinterpreted).

    This is one reason not to use the second form; the only reason it’s in the standard is to provide backward compatibility with (extremely) legacy code. If you’re using GCC, you can enforce this by using the -Wold-style-definition flag; I would hope that other compilers would offer something equivalent.

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

Sidebar

Related Questions

The C++ Standard states the following about virtual functions that have exception specifications: If
The standard explicitly states that main has two valid (i.e., guaranteed to work) signatures;
The C standard states: ISO/IEC 9899:1999, 6.2.5.15 (p. 49) The three types char, signed
The C++ standard (ISO/IEC 14882:03) states the following ( 2.11 / 2 ): Furthermore,
In the section covering setlocale, the ANSI C standard states in a footnote that
I have the following function that checks for a user login. At it's current
The C++0x standard working draft states (section 6.5.4) the following about the begin() and
The C++ Language Standard states the following concerning template components in the Standard Library:
The C++11 standard states that, if the conditions for copy elision are met (
As the question states, what date format is ds1248083197360 ? Is this a standard

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.