Compile issues

Apr 26, 2011 at 12:52 AM

Sorry for what is probably a dumb question - I'm just getting started with using PSTSDK and I cannot compile a test program. I'm using VC++ Express version 10.   I have the PSTSDK and BOOST directories in the compiler include path.  VC has no problem compiling the headers, but I get a compile error about "pst" being an undeclared identifier:

#include "pstsdk\pst\pst.h" int_tmain(int argc, _TCHAR* argv[])

pst p(L"c:/junk/txtesting.pst" 

);  

}

COMPILE ERRORS ...

 

1>c:\junk\testproj\testproj\testproj.cpp(11): error C2065: 'pst' : undeclared identifier

1>c:\junk\testproj\testproj\testproj.cpp(11): error C2146: syntax error : missing ';' before identifier 'p'

1>c:\junk\testproj\testproj\testproj.cpp(11): error C3861: 'p': identifier not found

 

{

printf("Starting open of .pst file\n" 

);
 

Coordinator
Apr 26, 2011 at 3:08 AM

The pst object is declared in the "pstsdk" namespace (as are all other objects in the sdk), so you'll either need to say:

 

pstsdk::pst p(L"myfile.pst");

 

Or at the top of your source file put:

 

using namespace pstsdk;

 

 

Apr 26, 2011 at 8:24 PM

Thanks.  Again, sorry for asking C++ questions in this forum, but I have primarily been doing 'C' and a lot of this is new to me.  Hopefully this is the last of them:

I am trying to put the declaration of the store inside a try/catch so that I do not get a runtime error if the supplied .pst name is invalid.  This works, but then VC does not recognize the store name if I use it later:

try {

  pst store(wpath);

}

catch (exception& e) {

   printf("Cannot open .pst file");

  return;

}

process_folder(0, store.open_root_folder());

This last statement generates the compile error "identifier store is undefined".  If I get rid of the try/catch it works.  How do I define 'store' in advance so that VC knows about it?

 

 

Coordinator
Apr 26, 2011 at 9:44 PM

You can't. Try putting all of your code in a helper function, and call the helper function from within a try/catch block.

Apr 26, 2011 at 10:23 PM

OK, but then I have the problem of how to return the pst object to the caller - not sure how to do that - can you give an example?  In any case, my intention is to use the sdk in a dll, with one routine that opens the .pst file, others to access it in various ways, so what I really need to do is define the pst object as a global variable - is that possible?  Or would I create the pst object in each routine that needs to access the .pst file?  That seems very inefficient, or would there be very little overhead doing that?

 

Jul 28, 2011 at 9:46 PM
Edited Jul 28, 2011 at 9:47 PM

Did you figure this out?

The one issue in your code is that the declaration of the PST object is inside a block, so it falls out of scope and goes away at the end of the try block. The easiest way to correct this is:

 

pstsdk::pst *store;

try {
  store = new pstsdk::pst(wpath);
}
catch (exception& e) {
   printf("Cannot open .pst file");
   return;
}

process_folder(0, store->open_root_folder());