Passing long pointer between files

I've been dabbling with DirectX for about a month now, and I'm trying to build separate classes for each individual component; Initialization, lights, texture and mesh loading, rendering, etc.
I'm splitting the components into .cpp and .h files accordingly, but I'm hitting a snag concerning the long-pointer to the D3D device.
Each component class needs the D3DDevice pointer, but every attempt to either pass it to the classes leads to compiler errors. Therefore, my question isn't about D3D, but rather how to get the long-pointer creator in the main D3D-initialization class to pass to the other files.

I suppose it comes down to this:
When I try to pass the pointer, it leads to a "d3ddev was nullptr" error at the recieving end(the class intended to use the passed pointer).
I've tried globalizing the pointer, but that only seems to work for the file that it's globalized in.
I realize it's most likely something right in front of me that I'm missing; I just can't find it.
Any help would be appreciated.
Cheers!
Last edited on
The symbol needs to have external linkage in order to share it between translation units. Functions, non-constant global variables and class names have external linkage by default, but not non-constant variables.

Declare it extern in every translation unit that requires it.
Define it once in a single source file.

Last edited on
Topic archived. No new replies allowed.