#if ((defined _Windows) || (defined _WINDOWS) || (defined _WIN32))
#define _TARGET_WINDOWS
#endif

#if defined unix
#define _TARGET_UNIX
#endif
int get_current_pid()
{
	#ifdef _TARGET_WINDOWS
	return ::GetCurrentProcessId() ;
	#else
	return ::getpid() ;
	#endif
}
This is general template for building error catching and handling mechanism.
try {
	... your code here ...
}
catch(std::exception &e) {
	// error handling
	std::cerr << e.what() << std::endl ;
}
catch(...) {  // unknown exception
	std::cerr << "unknown exception" << std::endl ;
}
Copyright (C) 2006 Andrey Mirzoyan