Mysterious undefined reference error

This is what my setup looks like:

#pragma once

extern const byte_t packed_image_data[221120];
extern const std::uint16_t tile_mapping[24035];
static const size_t packed_image_data_size = 221120;
static const size_t tile_mapping_size = 24035;

const byte_t packed_image_data[] = { /*...*/ };
const std::uint16_t tile_mapping[] = { /*...*/ };

#include "B.inl" 

And the errors:
1>Renderer.obj : error LNK2001: unresolved external symbol "unsigned char const * const packed_image_data" (?packed_image_data@@3QBEB)
1>Renderer.obj : error LNK2001: unresolved external symbol "unsigned short const * const tile_mapping" (?tile_mapping@@3QBGB)

I really don't understand why this isn't working. I do the exact same thing for other data arrays and it works fine. I can get it to link if I move the include directive to Renderer.cpp, but I just want to understand what I'm doing wrong. Looking at the generated .obj, I can see that the string "packed_image_data" does not appear anywhere, which would suggest the compiler has chosen not to generate a symbol for it, even though I can see the data is actually there. So I'm just stumped.
in B.inl #include "A.h"

looking through `nm', in changes from `r' to `R'
object file format. If lowercase, the symbol is usually local; if uppercase, the symbol is global (external).
Last edited on
It also works to use extern at the site of definition. But why is this necessary only for const globals?
seems that const implies static
Ah, I see. Alright, that answers my question, thanks.
Topic archived. No new replies allowed.