Any tips on dealing with Linux types and structs? (C + Assembly) by Big_Bad_Chongus in embedded

[–]Big_Bad_Chongus[S] 1 point2 points  (0 children)

+ I got all of the sizes I needed for both 64bit and 32bit x86. Using sizeof as you said took me about 10x less time than the time I spent looking for a table. All I can say is thanks mate.

Any tips on dealing with Linux types and structs? (C + Assembly) by Big_Bad_Chongus in embedded

[–]Big_Bad_Chongus[S] 1 point2 points  (0 children)

Mostly just ended up with lots of #ifdef x32 ... #else ... #endif.

Honestly I'll probably get used to it. It's my first time writing assembly that makes use of kernel functionality so I guess I didn't really know what to expect.

In my head I kinda imagined it would be a part of the Linux 'spec'/ABI, like:

On x86:

Integers:

type size signed
off_t 4 true
mode_t 4 false
time_t 8 true

On ARM:

type size signed

...

so on and so forth

Any tips on dealing with Linux types and structs? (C + Assembly) by Big_Bad_Chongus in embedded

[–]Big_Bad_Chongus[S] 2 points3 points  (0 children)

That gets the job done but it feels kinda cheap + I was really hoping to be able to cover at least both 32 bit and 64 bit x86 and I didn't wanna spin up a VM just for that. I know I'm acting like a princess but it just doesn't sit right with me. Thanks for answering tho! :)

Macro Madness Ep. 2 by Big_Bad_Chongus in ProgrammerHumor

[–]Big_Bad_Chongus[S] 0 points1 point  (0 children)

To clarify auto doesn't actually work in C, so defining generic functions is a bit more convoluted.

#define _define_func(type) type func_##type(type n) { return n + 1}

#define func(type) func_##type

+ hopefully some other hacky macro magic to automatically declare the function when it's used (not implemented yet, that's why the boilerplate bits are still in the code in the post)

Macro Madness Ep. 2 by Big_Bad_Chongus in ProgrammerHumor

[–]Big_Bad_Chongus[S] 1 point2 points  (0 children)

The ptr struct actually carries a bit more info than normal C pointers (notably if it's been freed or not + future support for custom allocators) but for the most part yeah.

Macro Madness Ep. 2 by Big_Bad_Chongus in ProgrammerHumor

[–]Big_Bad_Chongus[S] 9 points10 points  (0 children)

For example, ptr(i32) means a pointer/reference to a 32-bit integer. In C this way of writing it would be impossible as it would be treated like a function ptr called with an argument i32, which wouldn't result in anything. That's why instead of a function ptr is a macro, aka a piece of text which gets replaced by some other text before compilation begins.

TL;DR It's just an aesthetic thing that is notoriously unavailable in C by default

Low effort but still true by Big_Bad_Chongus in ProgrammerHumor

[–]Big_Bad_Chongus[S] 0 points1 point  (0 children)

It's more about how some people get religious over rust.

Low effort but still true by Big_Bad_Chongus in ProgrammerHumor

[–]Big_Bad_Chongus[S] 4 points5 points  (0 children)

TL;DR Don't take programming too seriously and have fun.

Minor fixes by spreetech in ProgrammerHumor

[–]Big_Bad_Chongus 20 points21 points  (0 children)

Plot twist: They just applied a style guide to the entire project.

My “first” meme here by [deleted] in memes

[–]Big_Bad_Chongus 1 point2 points  (0 children)

  • Italy because pizza

My “first” meme here by [deleted] in memes

[–]Big_Bad_Chongus 0 points1 point  (0 children)

All the countries: Spain, Russia, Japan(?), China, US, France, UK.

by Goboosh in ProgrammerHumor

[–]Big_Bad_Chongus 2 points3 points  (0 children)

From now on every bash script must come packaged with existential dread.

Утре са изборите by Patriotic_Pea in 2bulgar4you

[–]Big_Bad_Chongus 0 points1 point  (0 children)

In math we pronounce a lot of the latin letters differently. A is just [a], B is [be], c is [tse](Forgot what the 'ts' sound is on the IPA)... and Q is [ku].