I've been having a bit of trouble with external variables, and I was wondering whether anyone had an idea why this doesn't compile. (This is just example code, though it has the same errors).
As usuall, any help at all appreciated.Code://GLOBALS.H//////////////////////// #pragma once extern const int MAPH; extern const int MAPW; extern const int CELLSIZE; //////////////////////////////////////// //GLOBALS.CPP//////////////////// #include "globals.h" const int MAPH = 40; const int MAPW = 60; const int CELLSIZE = 10; /////////////////////////////////////// //FOO.H///////////////////////////// #pragma once #include "globals.h" void foo(int arr[][MAPH]); /////////////////////////////////////// //FOO.CPP///////////////////////// #include "globals.h" #include "foo.h" void foo(int arr[][MAPH]) { //do whatever } ////////////////////////////////////// //MAIN.CPP//////////////////////// #include "globals.h" #include "foo.h" int main() { int arr[MAPW][MAPH]; foo(arr); return 0; } //////////////////////////////////////



LinkBack URL
About LinkBacks




.
CornedBee