Re: unreachable code?
Could it be that in your compiler *somehow* exception handling is
disabled? Could it be that 'login' is declared with "throw()" (as
throwing nothing)? It's not your first day here. Post more code.
OK. I use VC++7.1. My compiler flags seem OK:
/Od /FD /EHsc /RTC1 /MTd /GS /c /ZI /Gd /TP
Here's the code (uncalled stuf removed)
extern "C"
{
int login( const char *);
int logout(const char *);
void lib_pexit(int);
SetFunctions(void*);
}
#define MAX_VERSION 2002
int g_Version = MAX_VERSION;
// get's called on error
void lib_pexit( int ErrorCode )
{
throw (1); // C4297 unexpected exception raised
}
int CheckFeature(const char* progstring, double version)
{
SetFunctions((void*)&lib_pexit); // register "lib_pexit" function
for (int nVersion = (int)version; nVersion<=tm.wYear+3; nVersion++)
{
g_Version = nVersion;
try
{
if (login(progstring) > 0)
{
g_Version = MAX_VERSION;
return 1; // OK
}
}
catch(int) // no hardlock
{
try
{
logout(NULL);
}
catch(int)
{;}
g_Version = MAX_VERSION; // C4702 unreachable code
}
}
g_Version = MAX_VERSION; // C4702 unreachable code
return 0;
}