munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
8.99k stars 1.05k forks source link

Doubts about using strucutre #957

Closed 724399396 closed 3 years ago

724399396 commented 3 years ago

Hi, Sorry i'm a newbee to c, in clox, Value is constructor like this NUMBER_VAL(value), run clox on ubuntu 20.02 desktop, i found Value structure is allocated on stack, will this cause strucutre in memory bits disturb by another method call?

munificent commented 3 years ago

No, it won't cause any problems. When you a return a value on the stack in C, it copies all of the bits.

724399396 commented 3 years ago

No, it won't cause any problems. When you a return a value on the stack in C, it copies all of the bits.

Thanks for your answer, i got it, structure is same as int.