高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】external linkage question
external linkage question
external linkage question
i am trying to build a sample application using the available documentation.
in the main.cpp, i have the following code.
// create a custom services object.
odrxobjectimpl<myservices> svcs;
odinitialize(&svcs);
:drxinitmodelergeometry();
oddbdatabaseptr pdb;
i would like the actual reading of the file in another file, e.g., readdwg.cpp with the ff code:
extern oddbdatabaseptr pdb;
int readdwg (char* szfilename)
{
pdb = svcs.readfile(szfilename);
}
i get the following error when i try to compile readdwg.cpp
error c2065: 'svcs' : undeclared identifier
error c2228: left of '.readfile' must have class/struct/union type
what additional code do i need to refer to the svcs object created in main.cpp?
thanks
you defined svcs in main.cpp and is trying to acces it from dwgread.cpp.....
sergey slezkin
quote:
originally posted by sergey slezkin
you defined svcs in main.cpp and is trying to acces it from dwgread.cpp.....
the reason i defined svcs in main.cpp is i wanted all initialization and uninitialization there while the actual reading of individual files are in a separate cpp file.
are you saying that there is no way to pass information from the svcs object created in main.cpp to a svcs.readfile function in dwgread.cpp? like via a global pointer?
if you define a global variable in one module and want to access it from another module you need declare it in another module by including a header with declaration or using "extern" statement like you did with pdb.
sergey slezkin
|