Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits) (+4)

Although Odin is rather a simple programming language, there are elements that one could find not so obvious and straightforward. This book helps to dispel misunderstandings and incorrect assumptions about Odin's inner behavior. And, honestly, it's neat to have such condensed source of information on hand, considering modest popularity of the language and lack of literature besides official overview and occasional articles.

That said, I have several nitpicks:

1) I think that not freeing memory in the end of a program is not generally a good advice, since, I believe, there are some OSes that do not free memory once a program is terminated.

2) In chapter 13.2

destroy_level :: proc(level: Level) {
    vmem.arena_destroy(&level.arena)
}

should be

destroy_level :: proc(level: ^Level) {
    vmem.arena_destroy(&level.arena)
}

since you'd get

Error: Cannot take the pointer address of 'level.arena'

otherwise.

3) In chapter 18.4

If you want a file to not compile on macOS and not compile on Linux, then add this to the top of the file:
#+build !windows
#+build !linux

should probably be

#+build !darwin
#+build !linux

4) In chapter 12.4

if logh_err == os.ERROR_NONE {
    log.destroy_file_logger(logger)
    os.close(logh)
}

there is no need to close handle, because

log.destroy_file_logger(logger)

looks like

destroy_file_logger :: proc(log: Logger, allocator := context.allocator) {
    data := cast(^File_Console_Logger_Data)log.data
    if data.file_handle != os.INVALID_HANDLE {
        os.close(data.file_handle)
    }
    free(data, allocator)
}

and calling

os.close(logh)

may lead to the

An invalid handle was specified.

error.

(+5)

Thanks a lot for the kind words and for buying the book!

Thank you for the list of issues. I have fixed 2, 3 and 4.

Regarding 1: There is no modern OS that leaks after shutdown. While there are some really old OSes where this could happen, Odin doesn’t support any of those OSes anyways. However, a good reason to do the deallocation at the end is to keep third-party memory analysis programs, such as Valgrind, happy. I have added a note about that in the book (update coming later today or tomorrow).