1, 2 or 3 Sup Forums?
1, 2 or 3 Sup Forums?
3 and only 3.
...
3
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()
{
}
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.
this, but at the very least put a space between the braces and parentheses
static int foo() { }
>grep
>source
why
You could grep for
int foo
for #2 and #3
static
int
foo
(
)
{
}
you would only find the first line of the definition?
3, what kind of question is this?
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
Or you could just use an actual editor/IDE and right click the call and select "Find Declaration"
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.*(
int
main
(void)
{
printf(
"Hello"
"World"
);
}
you would find where the function is defined
you are new
static int () foo{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
static
int
foo
(
)
{
}
;
This is best
depends entirely on what the current scope is.
>C toddlers on Sup Forums
It's fucking ugly code that shouldn't be written as such and you know it
They're not used a lot, the most recent example I saw #2 being used in was code for Inferno.
bitbucket.org
#1*
static int foo() {
// eotihhboeuhtnihhtn
}
...
pleb
#include\
"stdio.h"
int main
(
int
argc,
char
*
argv
[
]
)
{
printf
(
"Hello"
" "
"World"
"\n"
)
;
return
0
;
}
oh I fucked up
#include\
"stdio.h"
int
main
(
int
argc
,
char
*
argv
[
]
)
{
printf
(
"Hello"
" "
"World"
"\n"
)
;
return
0
;
}
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
;
}
static int foo(){
// shit goes here
}
fn foo() -> u32 {
}
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.
go home scala
no one likes you
gofmt
/thread
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.
>80 characters
I didn't realize it was still 1995. Go back to gamefaqs, dick lips.
>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
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!
I always put the { in the same line
dood this is not js
Works in C and C++ too
>my sides
#1
#2 is reasonable, though
int
main(int argc, char *argv[])
{
if(statement == true) {
// stuff
// other staff
} else {
// other shit
}
return stuff;
}
But you should know what the type returned by foo is
I don't know what are you trying to say
3
Close the thread before more stupid people talk
Using deprecated typed languages. You see the compute is smart enough to decide how something should be stored on memory.
user was probably just being dramatic.
good luck finding that one fucking opening bracket when you debug
we were doing fine before (You)r uneducated opinion
It's not an uneducated opinion.
1 and 2 are dumb and unnecessary.
ok I started using linux for the first time this week
what the fuck is foo
The only correct way
cvsweb.openbsd.org
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...
;_;
> * 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
}
this
int
main( int argc,
char** argv ) {
functionCall( );
statements;
return 0;
}
this style is the best
lmao do people actually do this
static
int
foo
{
}
is the best