几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】external linkage question (http://www.dimcax.com/hust/showthread.php?t=16265)

yang686526 2009-05-05 10:39 AM

【转帖】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


所有的时间均为北京时间。 现在的时间是 11:49 AM.