[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]

1, 2 or 3 /g/?

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: 69
Thread images: 3

File: TheGreatDebate.png (3KB, 200x238px)
TheGreatDebate.png
3KB, 200x238px
1, 2 or 3 /g/?
>>
3 and only 3.
>>
>>59012348
>>
>>59012348
WTF, didnt even know 1 and 2 would compile
>>
One shouldn't be afraid of making appropriate use of whitespace, but be reasonable. You shouldn't be thinking about splitting up your function until its parameters start pushing it above 80 characters.
>>
static int foo()
{
}
>>
>>59012409

With very few exceptions, newlines do not matter to a C or C++ compiler.
>>
#1 makes it possible to grep for
^foo(
and find the definition.
>>
>>59012429
this, but at the very least put a space between the braces and parentheses
static int foo() { }
>>
>>59012466
>grep
>source
why
>>
>>59012466
You could grep for
int foo

for #2 and #3
>>
static
int
foo
(
)
{
}
>>
>>59012466

you would only find the first line of the definition?
>>
>>59012348
3, what kind of question is this?
>>
>>59012483
have you never worked on even a moderately sized project?
>working in some file
>calls a function
>where the fuck is this function defined?
>grep '^function' *.c

easy
>>
>>59012507
Or you could just use an actual editor/IDE and right click the call and select "Find Declaration"
>>
>>59012527
either that, or use a source-code tagging program.

GNU GLOBAL is god-tier, I'm surprised it isn't more popular.

Alternatively if your codebase has declarations like number 3, you could just grep for:
static *int *foo.*(
>>
>>59012527
int
main
(void)
{
printf(
"Hello"
"World"
);
}
>>
>>59012491
you would find where the function is defined
>>
>>59012483
you are new
>>
>>59012675
static int () foo{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
>>
static
int
foo
(
)
{
}
;

This is best
>>
depends entirely on what the current scope is.
>>
>>59012409
>C toddlers on /g/
>>
>>59013412
It's fucking ugly code that shouldn't be written as such and you know it
>>
>>59012409
They're not used a lot, the most recent example I saw #2 being used in was code for Inferno.
https://bitbucket.org/inferno-os/inferno-os/src/d0f67301aeeadce718a5e0313cee03f4ab6b71b0/emu/port/alloc.c?at=default&fileviewer=file-view-default
>>
>>59013520
#1*
>>
>>59012348
static int foo() {
// eotihhboeuhtnihhtn
}
>>
>>59012489
>>
>>59012623
pleb
#include\
"stdio.h"

int main
(
int
argc,
char
*
argv
[
]
)
{
printf
(
"Hello"
" "
"World"
"\n"
)
;
return
0
;
}
>>
>>59014349
oh I fucked up
#include\
"stdio.h"

int
main
(
int
argc
,
char
*
argv
[
]
)
{
printf
(
"Hello"
" "
"World"
"\n"
)
;
return
0
;
}
>>
>>59014377
Now I present the "one token per line" style with proper indents
#include\
"stdio.h"

int
main
(
int
argc
,
char
*
argv
[
]
)
{
printf
(
"Hello"
" "
"World"
"\n"
)
;
return
0
;
}
>>
>>59012348
static int foo(){
// shit goes here
}
>>
fn foo() -> u32 {
}
>>
>>59014554
static int foo()
{
// shit goes here
}

FTFY
>>
whichever clang-format spits out.
>>
great, yet another low-hanging fruit discussion topic on which any retard who can write a hello world can have an opinion on.
>>
>>59014572
go home scala
no one likes you
>>
>>59012348
gofmt
/thread
>>
>>59013439
yes, but how could you not know that C is white-spaced agnostic?
>>
>mashing the function name up against the parameter list
You don't have to live like this.
static int foo ()
{
return bar();
}
>>
Anything but 3 is objectively and literally retarded.
>>
>>59012416
>80 characters

I didn't realize it was still 1995. Go back to gamefaqs, dick lips.
>>
>>59012507
>what are ctags
>what is using an IDE
>i'd rather keep to strict style so my shitty way of searching things works instead
>>
3

On a modern monitor vertical space is much more at a premium than horizontal

People who still stretch code vertically to save horizontal space so that the code wont fill more than half their 16:9 monitor's width are fucking barbarians.
>>
>not trying to make ASCII art that compiles

Are you some kind of, gay?
>>
const
char
foo[1]
{
'
a
'
,
'
b
'
,
'
c
'
,
.
.
.
}
;
>>
#include <stdio.h>

int main(){
int a = 3;
int b = 4;
int c,
d
=
5, 6;
while (true)
{
printf(
"OP is a fag \n"
);
}
}
>>
Now that's some CSS I can get behind!
>>
>>59014587
I always put the { in the same line
>>
>>59014554
dood this is not js
>>
>>59018666
Works in C and C++ too
>>
>>59018416
>my sides
>>
#1
#2 is reasonable, though
int
main(int argc, char *argv[])
{
if(statement == true) {
// stuff
// other staff
} else {
// other shit
}

return stuff;
}

>>59012488
But you should know what the type returned by foo is

>>59013160
I don't know what are you trying to say
>>
>>59012348
3

Close the thread before more stupid people talk
>>
>>59012348
Using deprecated typed languages. You see the compute is smart enough to decide how something should be stored on memory.
>>
File: 1485919594988.jpg (56KB, 640x640px)
1485919594988.jpg
56KB, 640x640px
>>59017586
Anon was probably just being dramatic.
>>
>>59018619
good luck finding that one fucking opening bracket when you debug
>>
>>59018845
we were doing fine before (You)r uneducated opinion
>>
>>59018935
It's not an uneducated opinion.

1 and 2 are dumb and unnecessary.
>>
>>59012348
ok I started using linux for the first time this week

what the fuck is foo
>>
The only correct way
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/bin/dd/dd.c?rev=1.23&content-type=text/x-cvsweb-markup

I told a guy at work, when we were talking about block opening style, that I use a newline when defining functions, but for all other cases use the same line. He looked at me like I was retarded...
;_;
>>
>>59020852

> * Copyright (c) 1991, 1993, 1994
>The Regents of the University of California. All rights reserved.

They think they have a copyright on their code hahaha
>>
static
int
foo
(
int
param1
,
int
param2
)
{
//do stuff
}
>>
>>59012466
this
>>
int
main( int argc,
char** argv ) {
functionCall( );
statements;
return 0;
}
>>
>>59020852
this style is the best
>>
>>59012466
>>59012507
lmao do people actually do this
>>
static
int
foo
{
}

is the best
Thread posts: 69
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.