0
enum  {
  ValidationLoginFailed=2000,
  ValidationSessionTokenExpired=2001,
  ValidationSessionTokenInvalid=2002,
  ValidationEmailNotFound=2003
  ValidationSucccesMIN=ValidationLoginFailed,
  ValidationSucccesMAX=ValidationEmailNotFound,
  ValdationValidSuccessCode=9999,
  ValdationInvalidCode=10000

}; 
typedef int ValidationStatusCodes;

please help me out.

Dan D.
  • 73,243
  • 15
  • 104
  • 123
user709877
  • 69
  • 8
  • 1
    Although it wouldn't affect the validity of the syntax, you misspelled `Success` as `Succces` in `ValidationSucccesMIN` and `ValidationSucccesMAX`. – icktoofay Apr 26 '11 at 04:41

1 Answers1

2

In your code, ValidationStatusCodes means int, not your anonymous enum type. So they aren't actually connected in any way.

However, since your enum contains int values, you could say that there's some sort of relation. You can pass the names of the enumerated values and they will be considered of the int or ValidationStatusCodes type.

By the way, Apple does something similar to what you do, except they typedef their collective names to NSInteger or NSUInteger instead of int or uint. See this question for an example.

With all that said, a more common practice is to typedef your custom type name directly to the anonymous enum, like this:

typedef enum {
    ValidationLoginFailed = 2000,
    ValidationSessionTokenExpired = 2001,
    ValidationSessionTokenInvalid = 2002,
    ValidationEmailNotFound = 2003
    ValidationSuccessMIN = ValidationLoginFailed,
    ValidationSuccessMAX = ValidationEmailNotFound,
    ValdationValidSuccessCode = 9999,
    ValdationInvalidCode = 10000
} ValidationStatusCodes;
Community
  • 1
  • 1
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
  • thanks. in my case. the return type of my method is an enum. so what return type should i give inside the brackets. – user709877 Apr 26 '11 at 05:34
  • @user: Whether you do `typedef int` or `typedef enum {...}`, your method should return `ValidationStatusCodes` – BoltClock Apr 26 '11 at 05:35