Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 3 [4]

Author Topic: Modding questions  (Read 9108 times)

Reelya

  • Bay Watcher
    • View Profile
Re: Modding questions
« Reply #45 on: November 09, 2014, 04:21:14 am »

If something is defined as extern, that's just a declaration not a definition, is there an actual cpp file where

FILE *my_new_file;

is declared without the extern parameter? This non-extern declaration is actually where the symbol itself is allocated to some chunk of memory. the extern copy is just the way of saying to the compiler "look, my_new_file is a thing, but it's actually created somewhere else, but I'm just telling you about it so you know. I'll tell you where it is when you need it".

Each .o file is created from a .cpp file during the compile stage, but they still contain "unlinked" references. Then in the linker stage, all the unlinked references (like extern stuff) are looked up in each .o file to see what they really point to. If there's no reference ("symbol not found") it means you either didn't create the actual FILE pointer, or didn't compile the cpp file that contains it.
« Last Edit: November 09, 2014, 04:30:33 am by Reelya »
Logged

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Modding questions
« Reply #46 on: November 09, 2014, 02:26:02 pm »

That worked; thank you very much!

I had thought that all of the externs were simply defined there, but I see they're in game.cpp as well. Good to know!
Logged
Pages: 1 2 3 [4]