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

calling-c: elaborate on the x_dpy example #525

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/c-ffi/calling-c.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ use @eglGetDisplay[Pointer[_EGLDisplayHandle]](disp: Pointer[_XDisplayHandle])
primitive _XDisplayHandle
primitive _EGLDisplayHandle

let x_dpy = @XOpenDisplay(Pointer[U8])
let x_dpy_name: String = // ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the code here already "doesn't compile" as it isn't valid. I don't think this change makes things better.

I think that this could be slightly better if the string is given a realistic display name.
This could be made "much better" by taking all the C calling code and make it "real" by putting the "FFI code examples" in code that would at least compile.

let x_dpy = @XOpenDisplay(x_dpy_name.cstring())
if x_dpy.is_null() then
env.out.print("XOpenDisplay failed")
end
Expand Down
Loading