[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

void foo() { Is there a reason for this other than "muh

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 11
Thread images: 3

File: 1462157350.jpg (79KB, 607x388px) Image search: [Google]
1462157350.jpg
79KB, 607x388px
void foo() {

Is there a reason for this other than "muh K&R"?
Obviously
void bar()
{

is much better
>>
No it doesn't
>>
The second one is K&R style you tard.
>>
>>60600181
>not voiding your functions
wew
>>
File: 1494138026375.png (628KB, 849x849px) Image search: [Google]
1494138026375.png
628KB, 849x849px
>>60600276
https://en.m.wikipedia.org/wiki/Indent_style#K.26R

>>60600181
With today's performance it's only a matter of taste. Just use whatever suits you and looks aesthetic too you.
Unless you're working on someone else's project, in which case use whatever style they prefer.
>>
How to spot a javascript faggot

if (cond) {
// ...
}


C++ developer master race

if (cond)
{
// statement
}


or

if (cond)
// single statement
>>
>>60600181
For function definitions like your example actually the second is K&R.

There's really no objective reason to use one over the other. Originally there was a reason for the discrepancy, see the wikipedia part right after what >>60601213 linked.
>>
File: ferris tea.png (502KB, 486x481px) Image search: [Google]
ferris tea.png
502KB, 486x481px
I use same-line brackets for enums, structs, unions and initalizer lists.
Functions use new-line brackets.
And for stuff like loops and control-flow statements, I like to avoid using brackets altogether.
Have you ever written a 5-level for loop guarded with only 1 semicolon?
Or how about a higher order conditional statement that makes heavy use of the return value of the assignment operator?
>>
There is no one superior way. It depends on the spec that the project adheres to.
>>
#include<u.h>
#include<libc.h>

void
main()
{
print("hello,world\n");
exits(0);
}
>>
>>60601213
Yea, the second one is k&r
k&r uses second style for functions (and since you posted a function, the second one is k&r)
k&r uses the first style for if statements, loop, etc
Thread posts: 11
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.