format for declaring variables?

C

CBFalconer

Christopher said:
.... snip ...
108
123 However, there is one special case, namely functions: they
124 have the opening brace at the beginning of the next line, thus:
125
126 int function(int x)
127 {
128 body of function
129 }

Not an anomaly, rather an outgrowth of the original K&R declaration
format:

int function(foo, bar)
int foo;
double bar;
{
body
}

and as such now often ignored by:

int function(int foo, double bar) {
body
}

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
B

Barry Schwarz

Function definitions are special in C.
Besides being the only exclusively external declarations,

The static keyword can remove the external attribute.
they are also the only declarations
that are not terminated by a semicolon.


Remove del for email
 
P

pete

Barry said:
The static keyword can remove the external attribute.

I don't think that you know what "external declarations" are.

N869
6.9 External definitions

Semantics

[#4] As discussed in 5.1.1.1, the unit of program text after
preprocessing is a translation unit, which consists of a
sequence of external declarations. These are described as
``external'' because they appear outside any function (and
hence have file scope).
 
B

Barry Schwarz

I don't think that you know what "external declarations" are.

You're probably right but the only reason I commented was because I
was thinking of external linkage which is unrelated to the topic under
discussion. My apologies.


Remove del for email
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top