/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

First for C++!

Why are you using C then?

Github

.section .data
character:
.ascii "1"
.section .text
.globl _start
_start:
#more code

is the ascii string there null terminated
has the ascii string there advanced my stack pointer or is it in the program memory (i.e. data, static), so the stack isn't touched?
if the stack has been advanced by the declaration of "character" by how much has it been advanced? I'd say 2 bytes, since '1' is a byte and '\0' another byte

basically my question is " ascii "1" " in data or on the stack?

I'm not.

>.section .data
that's not on the stack

what is the diffrence between stuff on the stack and on the heap?

What are you using then?

c++14
I thought the std::array would make it obvious

as i thought

text isn't on the stack either right

It's like Heisenberg's uncertainty principle: stuff on the stack, you know exactly where they are, but have no idea what's their momentum; what's on the heap, you have no clue where it is, but you know where it's going.

.text is static code, .data is static data.
on x86 both have their own segments, but I think they point to the same memory area.

thanks

static data is in a fixed location in memory:
mov eax, [ds:0x1234]
stack data is located on the stack:
mov eax, [ss:ebp-0x4]
heap is memory allocated by malloc/sbrk/new/etc, and is referenced through a pointer which can reside either in static data or on the stack:
mov eax, [ss:ebp-0x4]
mov eax, [eax]

You can have lambdas in C with gcc
void (*f)(void) =
({
void __fn__ (void) {
for (int i = 0; i < 100; i++)
printf("%d\n", i);
}
__fn__;
});
f();

and clang has blocks.
So you could write macro to wrap them but would limiting yourself to just gcc + clang be bad idea?

>would limiting yourself to just gcc + clang be bad idea?
Yes. Also that look fucking ridiculous.

I know Sup Forums told you how cool functional programming is, but when language limitations makes your shorthand anonymous functions neither shorthand nor anonymous then you might consider just using an actual function.

Why are almost all gcc extensions induce vomiting by looking at them?

>lambdas in C
stop right there. this is completely ridiculous. we have c++ nowadays.

>makes your shorthand anonymous functions neither shorthand
That's the definition you would write macro to make them, the macro would be the shorthand.

fuck c++

>fuck c++
stop cricicizing things you don't understand. learn it, love it.

Because GNU only makes dogshit.

Which are good alternatives to gcc and glbc?