BinaryByter
void foo(int z[10]); Z is simple pointer, not allocate memory
i'm pretty sure that that doesnt compile 😉
Daniele°
Try
Mihail
Still doesn't prove shit
BinaryByter
Might tho
oh wait this is a declaration and not a function call
BinaryByter
yea, i'm a potato 😂
Anonymous
No
Not sure
🐰🐾 سمیه
You are the one learning C tho
C is a language, not magic 😐
BinaryByter
void foo(int z[10]); Z is simple pointer, not allocate memory
it will allocate memory everytime you call the function - 10 bytes on the stack
Ибраги́м
Not sure what you referred to, though. Bother to explain your statement?
My statement is NOT to be explained, it's a position u attain with age, courage and maturity.
Daniele°
/c_gcc #include <stdio.h> void foo(int a[10]){ puts("lol"); } int main () { int k[4]; foo(k); return 0; }
Daniele°
Result: lol
Ибраги́м
C is a language, not magic 😐
Tldr; u are the wierdo here.
BinaryByter
No
except it will?
BinaryByter
BinaryByter
here
Mihail
No
It will lol
olli
share the link please. seems to be compiled w/o optimizations
🐰🐾 سمیه
Tldr; u are the wierdo here.
What does Tldr stands for? I dunno why no one welcomes C
BinaryByter
https://godbolt.org/z/2naz0X
BinaryByter
share the link please. seems to be compiled w/o optimizations
i'm not making a point about optimization
olli
i'm not making a point about optimization
the allocation is for the stack frame not the parameter
olli
void foo(int a[2000]){ puts("lol"); } allocates the same amount (16 B)
BinaryByter
the allocation is for the stack frame not the parameter
it allocates enough on the stack frame to accomodate to the parameter
Anonymous
My statement is NOT to be explained, it's a position u attain with age, courage and maturity.
Because you don't seem to have any clue about what you said, you should have added "in my opinion" part in this case, then nobody would ask you to explain your statement.
Mihail
the allocation is for the stack frame not the parameter
Why would there be a stack frame in that function?
olli
Why would there be a stack frame in that function?
Why not? compilers tend to create stack frames for every function call without any optimizations since it's easier to read and debug
BinaryByter
BinaryByter
but it still allocates memory
BinaryByter
olli
Prolly
foo(int*): mov edi, OFFSET FLAT:.LC0 jmp puts https://godbolt.org/z/UApcOF
Daniele°
You Need to binding Array into structure for allocate Memory in function arg
Ибраги́м
i'm pretty sure that that doesnt compile 😉
I'm pretty sure it does and the guy is correct
Daniele°
struct lol{ int a[10]; }; void foo(struct lol a); This reserve Memory to array
olli
obviously. That's why it doesn't really make sense to argue about non optimized code
Mihail
Btw Olli what's your opinion on the statement that [] is *?
klimi
Have fun geniuses
Mihail
In a function argument, yes
In a specific context yes
olli
It decays to a pointer if used for parameters, but is not the same
Mihail
In general no
BinaryByter
Ибраги́м
What does Tldr stands for? I dunno why no one welcomes C
Tldr: Too Long Don't Read. U know another thing C stands for? CANCER!
Nomid Íkorni-Sciurus
It decays to a pointer if used for parameters, but is not the same
is it because [] realigns the blocks while * doesn't?
Daniele°
In a specific context yes
but there was talk of a parameter of function
BinaryByter
but [] allocates memory to the stack or heap
BinaryByter
while * only decalres a pointer
olli
Ибраги́м
void foo(int z[10]); Z is simple pointer, not allocate memory
Another reason why u should hate C. @one6away Hooray for std::array, one true array.
BinaryByter
no. Not if used as parameter
We are specifically talking about that case
olli
We are specifically talking about that case
than add it. Otherwise it's confusing to read the message alone
Ибраги́м
no. Not if used as parameter
Language lawyer, let's find the line in our book of law.
Ибраги́м
Stupid reason
Yea, to the untrained eye.
Mihail
but there was talk of a parameter of function
Yes so I mentioned how that's not true except in a specific context and you started arguing
Daniele°
Yea, to the untrained eye.
oop on C++ is very old style
BinaryByter
oop on C++ is very old style
no, its how you use OOP on C++ that is very old style
BinaryByter
you can do modern Coding in C even
Ибраги́м
oop on C++ is very old style
No, no we don't do that in here. I didn't mention OOP tho. And does C even have OOP? If C++'s OOP is old, C's is non-existent.
Ибраги́м
Ибраги́м
Heck, the hurt of Macros is still there
BinaryByter
Uhm... lambda ?
function pointer :D
Ибраги́м
C does have OOP, but its hacky
Non-existent, period!
Daniele°
oop in C++ is very old