![]() |
【转帖】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 |
所有的时间均为北京时间。 现在的时间是 04:30 PM. |