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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:56:00+00:00 2026-05-27T00:56:00+00:00

If a function were compiled separately, the mismatch would not be detected, the function

  • 0

If “a function” were compiled separately, the mismatch would not be detected, “the function” would return a double that main would treat as an int… In the light of what we have said about how declarations must match definitions this might seems surprising. The reason a mismatch can happen is that if there is no function prototype, a function is implicitly declared by its first appearance in an expression, such as

    sum += "the function"(line);

If a name that has not been previously declared occurs in an expression and is followed by a left parenthesis, it is declared by context to be a function name, the function is assumed to return an int, and nothing is assumed about its arguments.

I apologize beforehand for the ambiguous question, but what does this mean?

By the way this is page 73 chapter 4.3 from Brian W. Kernighan and Dennis M. Ritchie’s C Programming Language book, 2nd edition.

  • 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-27T00:56:00+00:00Added an answer on May 27, 2026 at 12:56 am

    K&R2 covers the 1989/1990 version of the language. Later editions of the ISO C standard (1999, 2011, etc.), drop the "implicit int" rule, and requires a visible declaration for any function you call. Compilers don’t necessarily enforce this by default, but you should be able to request more stringent warnings — and you definitely should. In well-written new code, the rule is irrelevant (but it is necessary to understand it).

    An example: the standard sqrt() function is declared in <math.h>:

    double sqrt(double);
    

    If you write a call without the required #include <math.h>:

    double x = 64.0;
    double y = sqrt(x);
    

    a C90 compiler will assume that sqrt returns int — and it will generate code to convert the result from int to double. The result will be garbage, or perhaps a crash.

    (You could manually declare sqrt yourself, but that’s the wrong solution.)

    So don’t do that. Always include whatever header is required for any function you call. You might get away with calling an undeclared function if it does return int (and if your compiler doesn’t enforce strict C99 or C11 semantics, and if a few other conditions are satisfied), but there’s no good reason to do so.

    Understanding the "implicit int" rule is still useful for understanding the behavior of old or poorly written code, but you should never depend on it in new code.

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

Sidebar

Related Questions

I have many structs (classes) and standalone functions that I like to compile separately
Template code is not compiled until the template function is used. But where does
Visual C++ is saying my void function needs a return value I compiled this
I have a function that uses Pattern#compile and a Matcher to search a list
When we compile a dll using __stdcall inside visual studio 2008 the compiled function
I would like to precalculate values for a function at compile-time. Example (real function
I'm writing a module with mixin templates to supply a main function for unit-testing
I'm planning to release some compiled code that shall be linked by client applications
I have a class 'Vector3' which is compiled successfully. It contains both non-friend and
I have a strange error that has bothered me all day. I have a

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.