James Eichele
James Eichele

Reputation: 119154

What are the names used to describe the "top" and "bottom" portions of a C-style function definition?

I am looking for a name or phrase to identify two distinct parts of a function definition

1. The part that looks exactly the same as the function declaration (minus the semi-colon)
2. The rest (the portion within and including the curly-braces)

int someFunction(int value, bool flag)  // part one
{ ... }                                 // part two

Is there an accepted way to describe these two parts?

Upvotes: 1

Views: 172

Answers (6)

John Bode
John Bode

Reputation: 123478

Here's the grammar for a function definition:

function-definition:
    declaration-specifiers declarator declaration-listopt compound-statement

Normally I don't really distinguish between the two. If pressed, I'd use "body" for the {...} portion, and either "signature" or "prototype" for the rest.

Upvotes: 1

AProgrammer
AProgrammer

Reputation: 52294

I'd use prototype and body. Body is use widely for that purpose, prototype has formally a slightly different meaning.

Edit: The standard use function declarator (sometimes abbreviated to declarator) and body. For instance in 6.9.1/13 which is an example stating

In the following:

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

extern is the storage-class specifier and int is the type specifier; max(int a, int b) is the function declarator; and { return a > b ? a : b; } is the function body.

Upvotes: 2

pmg
pmg

Reputation: 108938

main has no prototype -- so says the Standard -- and I kinda dislike header.

So I call them 'function signature' and 'function body'.

Upvotes: 1

Darkn3ss
Darkn3ss

Reputation: 151

Functions have the function prototype declaration, definition, and body.

void SomeFunction(void);  //Prototype declaration.

void SomeFunction(void) /*Function Definition*/ { /*Function Body*/ }

Upvotes: 1

DavidMFrey
DavidMFrey

Reputation: 1668

Here's an interesting tidbit on it... http://msdn.microsoft.com/en-us/library/w3sez2yb.aspx

part one can be the function prototype, part two is called the function body.

Upvotes: 1

David Thornley
David Thornley

Reputation: 57046

I call them the function header and function body. A quick glance at Harbison & Steele comes up with no real names for them.

Upvotes: 3

Related Questions