-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature request: make types marked with exportc always emitted #7448
Comments
|
Is this an issue? What's wrong with |
Currently |
Can confirm that this is annoying. Just tried this: {.push exportc, used.}
type
DisplayKind* {.exportc.} = enum
Text, Circle, RawPixels
RGB565* {.exportc.} = uint16
Display* {.exportc: "Display", used.} = object
case kind*: DisplayKind
of Text:
text: cstring
textColor: RGB565
of Circle:
radius: uint8
circleColor: RGB565
of RawPixels:
data: array[16, array[16, RGB565]]
pos: tuple[x, y: uint8]
AnimationKind* {.exportc.} = enum
Scroll,
Animation* {.exportc.} = object
case kind*: AnimationKind
of Scroll: discard
The C code does not have these types. |
Exportc affects mangling and shouldnt be conflated with feature request |
I would be fine with it |
Used (extending its current meaning) or export |
Based on @dom96 repro, I don't see how this isn't a bug and not a feature request. |
dead code elimination (DCE) (whether for procs or types) is useful, and exportc + exportcpp should IMO only affect mangling, not dead code elimination.
if we change semantics to make exportc types inhibit DCE, we at least need a new pragma to honor DCE. Alternatively (IMO, preferably), we can change semantics for exportc procs to honor DCE (with a legacy transition switch), and make |
|
Well if you export to C, you want a stable name too so this conflation of concerns is entirely reasonable. Not sure what exporting a type to C brings us though. If you export a proc, it ends up in your binary, if you export a type, it ends up in a single C file, what's the point? We don't generate C header files. |
We do. There is a |
It was not supposed to be used and was going to be deprecated iirc |
Why? Any links to where this is discussed? |
It's one of these features we cannot maintain and the code generator wasn't build for... It was useful to somebody once and now is a burden. Some lessons to be learned from this here... |
deprecating --header should be the type of thing that requires an RFC, IMO. |
Currently compiler eliminates all unused types. Make it possible to force type definition to be emitted.
Pragma
exportc
seems to be suitable. Another option isused
pragma.The text was updated successfully, but these errors were encountered: