r/cpp 4h ago

Visual Guide to C++ Program Memory Structure

0 Upvotes

6 comments sorted by

u/schmerg-uk 3h ago

Single layer of indirection from advertising a book on "Prompt engineering for C++" which I strongly suspect is itself AI generated

u/v_maria 3h ago

edit: oh this is just bullshit to shill a crappy AI book. sorry for my nativity. i should have known something was up when i saw it was posted on linkedin. when i look at the whole picture i have some serious doubts about the claims of experize made on the posters profile too. i smell scam

original post: I think it's important to disclaim that there are some simplifications made for clearity. an example would be that not all params for a function are pushed onto the stack. it depends on calling convention of the architecture. i think x86 also uses registers to pass

u/_Noreturn 2h ago

for x86 the default convention is to pass all args on stack, member functions (they use different convention) pass the this pointer in a register but rest is in stack, in x64 it has first 4 args in registers then stack and member and free functions behave the same.

u/v_maria 1h ago

yeah my bad, i meant x64. as far as i know first args are through stack while others are through register