Skip to content

Commit 0ab5a04

Browse files
committed
Add at-cfunction
1 parent 0f612e1 commit 0ab5a04

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ Currently, the `@compat` macro supports the following syntaxes:
411411

412412
* `isalpha` is now `isletter` ([#27077]).
413413

414+
* `cfunction` is now `@cfunction` ([#26486]).
415+
414416
## New macros
415417

416418
* `@__DIR__` has been added ([#18380])
@@ -635,6 +637,7 @@ includes this fix. Find the minimum version from there.
635637
[#26369]: https://github.com/JuliaLang/julia/issues/26369
636638
[#26436]: https://github.com/JuliaLang/julia/issues/26436
637639
[#26442]: https://github.com/JuliaLang/julia/issues/26442
640+
[#26486]: https://github.com/JuliaLang/julia/issues/26486
638641
[#26660]: https://github.com/JuliaLang/julia/issues/26660
639642
[#26670]: https://github.com/JuliaLang/julia/issues/26670
640643
[#27077]: https://github.com/JuliaLang/julia/issues/27077

src/Compat.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,14 @@ end
18661866
const isletter = isalpha
18671867
end
18681868

1869+
# 0.7.0-DEV.4762
1870+
@static if !isdefined(Base, Symbol("@cfunction"))
1871+
macro cfunction(f, rt, tup)
1872+
:(Base.cfunction($f, $rt, Tuple{$tup...}))
1873+
end
1874+
export @cfunction
1875+
end
1876+
18691877
include("deprecated.jl")
18701878

18711879
end # module Compat

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,4 +1714,11 @@ end
17141714
@test isletter('β')
17151715
@test !isletter('3')
17161716

1717+
# 0.7.0-DEV.4762
1718+
let ptr = @cfunction(+, Int, (Int, Int))
1719+
@test ptr isa Ptr{Cvoid}
1720+
@test ptr != C_NULL
1721+
@test ccall(ptr, Int, (Int, Int), 2, 3) == 5
1722+
end
1723+
17171724
nothing

0 commit comments

Comments
 (0)