Suraj K Thomas
Suraj K Thomas

Reputation: 5883

Swift Compiler Error Redefinition of 'ACTION'

I am getting the above error in my program.Im using C++ code in swift (with objective c).Its giving a conflict with an enum present in IOS 8.4 framework file(IOS 8.4->usr/include->search.h).If i change the name of enum the error is solved but i would like to know the reason of the error .Any valuable thoughts are welcomed .Please see the screenshots error message

location of conflict flie conflict file

Have a look at the enum code in both conflict files main.h

    enum FilterConfigurationOrder
{
  NAME_WITH_CREATOR,  // name@mobile
  FROM_HHMM,
  TO_HHMM,
  FROM_YYYYMMDD,
  TO_YYYYMMDD,
  FROM_MOBILE,
  TO_MOBILE,
  FROM_LATITUDE,
  TO_LATITUDE,
  FROM_LONGITUDE,
  TO_LONGITUDE,
  AREANAME,
  IS_WITHIN_AREA,
  LOCATIONS_PER_MESSAGE,
  EVERY_X_MINUTES,
  ON_X_DAYS,
  ACTION1,
};

code in search.h

typedef enum {
    FIND, ENTER
} ACTION;

Upvotes: 0

Views: 303

Answers (1)

CygnusX1
CygnusX1

Reputation: 21818

enum values share the same namespace as variables and typedefs within the context where the enum itself is being defined.

enum Foo {
    Bar;
}

typedef int Bar;

int main() {
    Bar ... //do I refer to typedef or enum value?
}

C++11 introduced a new construct "enum class" with its members being put in a separate name space under the enum name:

enum class Foo {
    Bar;
}

typedef int Bar;

int main() {
    Bar ... //typedef
    Foo::Bar ... //enum value
}

Upvotes: 1

Related Questions