Using an enum in other cpp files

I am currently writing an arduino program for my modeltrack. This program will be used for detectors, switches and memory layouts. I will add signal lights and perhaps more things in the future.

A button, an LED or a switch or whatever may be wired to an aruino IO or it may be wired to the MCP23017 I2C IO extender.

The main program contains an enum:

enum mcp23017 {
  MCP23017 = 0x20,
  IODIRA = 0x00,
  IODIRB = 0x01,
  portA = 12,
  portB = 13};

It is the idea that the constants of this enum are accessable in all other cpp files because now they are not.

Wire.beginTransmission(MCP23017);

results in ‘MCP23017’ was not declared in this scope

I believe the keyword extern needs to be used but I am unsure how?

Can anybody tell me the easy way of making the elements of this enum accessable in all included cpp files?

EDIT:
nvm. Found the solution. I made a new header files with the extern made enum and I #include this files where eevr needed

If you want to use something in "multiple cpp files", you have to declare it in a header file and include that header file in each cpp file where you need it.

With type declarations (enums, classes, etc.) it is easy: create a header file and put your enum declaration in there. Most likely it will end up being a header file that will contain many different declarations of things that you want to be globally accessible, so don't assume that you are creating it just for that enum.

bask185:
I believe the keyword extern needs to be used but I am unsure how?

No, keyword extern is mostly needed when declaring global variables. Enum type and its members are not variables. No extern needed.

bask185:
nvm. Found the solution. I made a new header files with the extern made enum and I #include this files where eevr needed

Um... "with the extern made enum" - what does that mean? What is extern doing here?