munificent / craftinginterpreters

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

function declaration forgotten (14.5.3) #968

Closed olibertrand closed 3 years ago

olibertrand commented 3 years ago

Hi, Thank you for this fantastic work, I'm getting each day deeper in it. I'll write a note when I'll have integrated most of it.

For now I just wanted to point a small omission in 14.5.3: the declaration static int constantInstruction(const char* name, Chunk* chunk,int offset); has to be added in debug.h (yeah, it's obvious - just to keep as precise as the rest of the book)

regards - you're enlightening my life Olivier Bertrand

jcgoble3 commented 3 years ago

It doesn't, because the word static means it's not visible outside the debug.c file anyway. No other source file needs that function. Only functions that other source files might need access to need to be declared in a header file.

munificent commented 3 years ago

@jcgoble3 is right. :) It doesn't need to be in the header. (As you get farther into the C implementation, you'll see lots more static functions that aren't in the headers.)

olibertrand commented 3 years ago

makes sense - sorry for the distraction. I had written it after a non-static declaration, which explains the compilation failure.