Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this kind of coding style in c?

Tags:

c

coding-style

(void) fputs( line, stdout );
(void) alarm( TIMEOUT );

The above appears in the function body,I've never seen such code before...

like image 964
kern Avatar asked May 18 '11 13:05

kern


People also ask

What is programming style in C?

Programming style, also known as code style, is a set of rules or guidelines used when writing the source code for a computer program. It is often claimed that following a particular programming style will help programmers read and understand source code conforming to the style, and help to avoid introducing errors.

What is K & R style?

K&R style minimises the amount of vertical space which the code consumes, while maintaining that the syntax of the control structure itself does not share lines with its contents. Ensuring a control structure doesn't share lines with its content is important.

What is a good coding style?

Some general advice on good coding style Good code is self-explanatory – the need for comments should be minimal. Comments should be added to those parts of the code where explanations are needed. With code one should not be clever if it is not necessary – do things in an obvious straightforward way.

Does C use Camelcase?

Classic C doesn't use camel-case; I've written code in camel-case in C, and it looks weird (so I don't do it like that any more). That said, it isn't wrong - and consistency is more important than which convention is used.


1 Answers

It's a form of coding to debugging tools at the expense of human beings reading your code, and it's Considered Harmful. In particular, the classic lint tool and perhaps some compilers generated warnings if you did not use the return value of a function that returned a value, and the only way to suppress this locally was to cast the result to void.

Either ignore it, or fix it (remove the useless void casts) if you have sufficient authority to do so.

like image 110
R.. GitHub STOP HELPING ICE Avatar answered Sep 22 '22 16:09

R.. GitHub STOP HELPING ICE