Joe
unread,Jun 8, 2015, 10:26:23 PM6/8/15You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I've got a header that extern declares a var which is defined within a
globals.cpp. I do this for very few globals.
--- globals.h
#pragma once
extern MyGlobalClass my_gclass;
--- globals.cpp
MyGlobalClass my_gclass;
--- aclass.h
#include "globals.h"
template <class SomeClass>
class AnotherClass
{
// ...
void operator()() {
my_gclass->func(...);
}
};
The problem is that it won't compile.
aclass.h:102:29: error: 'my_gclass' was not declared in this scope
error = my_gclass->func(...
I don't understand that since the #include "globals.h" is in aclass.h.
However, if I add "extern MyGlobalClass my_gclass;" just after #include
"globals.h in the aclass.h template file, it works.
Can someone explain this?