Can't {.exportc.} enums #826

Closed
gradha opened this Issue Jan 19, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@gradha
Contributor

gradha commented Jan 19, 2014

The following code doesn't compile:

type
  TheStruct* {.exportc.} = object
    value: string
    typ: TDirection

  TDirection {.exportc.} = enum
    north, east, south, west

const
  TDirectionNorth {.exportc.} = north

proc test_native() {.exportc.} =
  var
    ns: TheStruct
    ab = TDirectionNorth
  {.emit:"""TheStruct theS;""".}
  # Next line doesn't compile.
  {.emit:"""TDirection dummy = TDirectionNorth;""".}
  echo "I love enums!"

when isMainModule:
  test_native()

The enums don't appear in the C code. The attempt to wrap them through a constant didn't work either, none appear in the generated C code. The structure just gets the NU8 type.

@Araq

This comment has been minimized.

Show comment
Hide comment
@Araq

Araq Feb 2, 2014

Member

We should simply document that this is currently not supported.

Member

Araq commented Feb 2, 2014

We should simply document that this is currently not supported.

Araq added a commit that referenced this issue Feb 3, 2014

@gradha gradha closed this Feb 3, 2014

gradha added a commit that referenced this issue Apr 7, 2014

Araq added a commit that referenced this issue Apr 7, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment