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

try/catch doesn't work with C interop and structs #10

Open
geekrelief opened this issue Jan 21, 2022 · 0 comments · May be fixed by #12
Open

try/catch doesn't work with C interop and structs #10

geekrelief opened this issue Jan 21, 2022 · 0 comments · May be fixed by #12

Comments

@geekrelief
Copy link
Contributor

I've been working with a C library, and the try/catch mechanism doesn't work well for digging into structs.

For example, I call function that returns a ptr.

  let draw: ptr tm_creation_graph_draw_call_data_t = render_component_api.draw_call(...)

  if ?draw.shader: 
    # do stuff

If draw is nil then I'll get a crash because the access violation is coming from C and not from Nim. My work around is to use my conditional access macro that does checks at each step.

  if ?draw.?shader:
    # do stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant