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

No-arg Ptr constructor. #30919

Merged
merged 4 commits into from Feb 16, 2019

Conversation

@malmaud
Copy link
Contributor

commented Jan 31, 2019

Lets you write e.g. Ptr{Cvoid}() as a shorthand for Ptr{Cvoid}(0). Nice for when you're creating a bunch of pointers you're going to pass as references to C libraries to set so you don't care about the initial value.

base/boot.jl Outdated Show resolved Hide resolved
@maleadt

This comment has been minimized.

Copy link
Member

commented Feb 1, 2019

Nice for when you're creating a bunch of pointers you're going to pass as references to C libraries to set so you don't care about the initial value.

Isn't that what Ref is for? ie. Ref{T}()

@malmaud

This comment has been minimized.

Copy link
Contributor Author

commented Feb 1, 2019

I wanted to call a C function that sets an array of pointers,

ptrs_out = [Ptr{Cvoid}() for _ in 1:10]
ccall(..., (Ptr{Cvoid},), ptrs_out)

Even if there's a different way of doing that, it still seems to sensible to default pointers to C_NULL, doesn't it?

@ararslan

This comment has been minimized.

Copy link
Member

commented Feb 4, 2019

Looks like you'll need to rebase on master.

@malmaud malmaud force-pushed the ptr_init branch from b608e11 to f1da8e2 Feb 5, 2019

@malmaud malmaud force-pushed the ptr_init branch from f1da8e2 to 6e87328 Feb 14, 2019

@malmaud malmaud merged commit 28c3dd0 into master Feb 16, 2019

2 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
julia freebsd ci Build done
Details

@malmaud malmaud deleted the ptr_init branch Feb 16, 2019

@@ -8,6 +8,13 @@ memory is actually valid, or that it actually represents data of the specified t
"""
Ptr

"""

This comment has been minimized.

Copy link
@KristofferC

KristofferC Feb 17, 2019

Contributor

@fredrikekre should this have a compat annotation?

@fredrikekre

This comment has been minimized.

Copy link
Member

commented Feb 21, 2019

Seems like this is causing

WARNING: Method definition (::Type{Ptr{T}})() where {T} in module Compiler at pointer.jl:16 overwritten in module Base at pointer.jl:16.

during sysimg build time.

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