Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen bug with exportc #9297

Closed
cooldome opened this issue Oct 10, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@cooldome
Copy link
Member

commented Oct 10, 2018

the following example does not compile (generated C does not compile), without exportc pragma it compiles without issues.

import strutils

type
  MyKind = enum
    M1, M2, M3

  MyObject {.exportc: "ExtObject"} = object
    case kind: MyKind
      of M1: a:int
      of M2: b:float
      of M3: c:cstring

proc newMyObject(kind: MyKind, val: string): MyObject =
  result.kind = kind
  case kind
    of M1: result.a = parseInt(val)
    of M2: result.b = parseFloat(val)
    of M3: result.c = val

echo newMyObject(M1, "2")

I will submit a PR to fix it

cooldome added a commit to cooldome/Nim that referenced this issue Oct 10, 2018

@cooldome cooldome referenced this issue Oct 10, 2018

Merged

fixes #9297 #9298

@Araq Araq closed this in #9298 Oct 11, 2018

Araq added a commit that referenced this issue Oct 11, 2018

fixes #9297 (#9298)
* fixes #9297

* improve spacing

krux02 added a commit to krux02/Nim that referenced this issue Oct 15, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Oct 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.