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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:43:20+00:00 2026-06-01T19:43:20+00:00

Today Clang, trying to compile a program, gave me kinda an strange message. I’m

  • 0

Today Clang, trying to compile a program, gave me kinda an strange message. I’m not really experienced with C, so I might be doing something wrong, but the code that I actually tried is this:

#include <stdio.h>
#include <stdlib.h>

int sum(a,b);

int main ()
{
    printf(sum(1,2));
    return 0;
}

int sum (int a, int b)
{
    return a + b;
}

As you have probably noticed, when declaring the function ‘sum’, I’m not including the param. type, so an error is expected, but the actual message Clang gives me is this:

ind.c:4:9: error: a parameter list without types is only allowed in a function definition
int sum(a,b);
        ^
ind.c:12:5: error: redefinition of 'sum' as different kind of symbol
int sum (int a, int b)
    ^
ind.c:4:5: note: previous definition is here
int sum(a,b);
    ^
2 errors generated.

What does Clang mean when it says it is only allowed in function definitions? Isn’t int sum(a,b); a function definition?

  • 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-06-01T19:43:21+00:00Added an answer on June 1, 2026 at 7:43 pm

    No, int sum(a, b); is, or rather looks like, a function declaration, not a definition.

    A function declaration provides enough information for the compiler to generate calls to the function. A definition provides a declaration and, in addition, defines the code that will be executed when the function is called (the stuff between { and }).

    A function declaration (that’s not part of a definition) may include the types of the parameters, or the types and their names, but not just their names. (If it includes the types, it’s a prototype.)

    An old-style function definition can have just the names of the parameters, for example:

    int sum(a, b)
    int a;
    int b;
    {
        return a + b;
    }
    

    But old-style definitions and declarations are obsolescent, and are best avoided. An old-style declaration doesn’t specify the number of type(s) of the parameters, so the compiler can’t verify the correctness of calls.

    Your declaration could look like this:

    int sum();
    

    but it should look like this:

    int sum(int a, int b);
    

    or even this:

    int sum(int, int);
    

    Oh, and int main () is better written as int main(void).

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

Sidebar

Related Questions

today I'm trying to optimize my website for a better rendering in firefox! my
Today we have received some strange exceptions on our production website. They all have
Today at work we came across the following code (some of you might recognize
I just came across Clang/LLVM today , and decided to try it out. My
Today somebody told me that interface implementation in C# is just Can-Do relationship, not
today i was facing a strange problem: got a 'missing method' error on a
Today I have faced very strange behavior of sqlite3_finalize statement. I am using sqlite
Today I found a weird problem, I was trying to fire a DropDownList SelectedIndexChanged
Today I observed a strange behavior I am hoping I can get some direction
Today I had a nice opportunity from my manager to propose new technologies to

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.