I\'m testing code remotely on a Solaris machine through SSH Secure Shell using c++. Not sure of what version anything is; Solaris, the c++/compiler, etc. (and don\'t know ho
enum STR_TO_INT_STATUS { SUCCESS, OVERFLOW, UNDERFLOW, INCONVERTIBLE };
Perhaps on of the enumerators like SUCCESS
was already previously defined. Try using SUCCESS_TEST or something to verify this.
Another way to verify this is to compile the code with the -E
option, this shows the preprocessor output. For example: gcc -E main.cpp
My guess is that either <limits>
or <cmath>
have defines for one or more of SUCCESS
, OVERFLOW
, UNDERFLOW
, INCONVERTIBLE
, which causes your enum identifiers to be converted to "numeric constants", which in turn would cause the errors that you are seeing.
You don't see them in the first version because you didn't include those headers.
Simple way to check: Try renaming the enum identifiers.
The include of cmath
is defining preprocessor constants OVERFLOW
as 3 and UNDERFLOW
as 4. So the line declaring the enum becomes (if there are no other constants):
enum STR_TO_INT_STATUS { SUCCESS, 3, 4, INCONVERTIBLE };
which, of course is not valid syntax.
I think it's the following line:
int size_of( int );
...should be something more like:
int sizeOfInt = size_of( int );
edit
I just compiled it on my machine and it's your OVERFLOW
definition... #define's are evil!
Try this:
enum STR_TO_INT_STATUS { STR_TO_INT_SUCCESS, STR_TO_INT_OVERFLOW, STR_TO_INT_UNDERFLOW, STR_TO_INT_INCONVERTIBLE};