diff --git a/README.md b/README.md index 50b8008cd..b46c36118 100644 --- a/README.md +++ b/README.md @@ -411,6 +411,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `isalpha` is now `isletter` ([#27077]). +* `cfunction` is now `@cfunction` ([#26486]). + ## New macros * `@__DIR__` has been added ([#18380]) @@ -635,6 +637,7 @@ includes this fix. Find the minimum version from there. [#26369]: https://github.com/JuliaLang/julia/issues/26369 [#26436]: https://github.com/JuliaLang/julia/issues/26436 [#26442]: https://github.com/JuliaLang/julia/issues/26442 +[#26486]: https://github.com/JuliaLang/julia/issues/26486 [#26660]: https://github.com/JuliaLang/julia/issues/26660 [#26670]: https://github.com/JuliaLang/julia/issues/26670 [#27077]: https://github.com/JuliaLang/julia/issues/27077 diff --git a/src/Compat.jl b/src/Compat.jl index 51b16ae37..7d37d3eba 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1866,6 +1866,14 @@ end const isletter = isalpha end +# 0.7.0-DEV.4762 +@static if !isdefined(Base, Symbol("@cfunction")) + macro cfunction(f, rt, tup) + :(Base.cfunction($f, $rt, Tuple{$tup...})) + end + export @cfunction +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 25d6cae69..59eaa6ab5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1714,4 +1714,11 @@ end @test isletter('β') @test !isletter('3') +# 0.7.0-DEV.4762 +let ptr = @cfunction(+, Int, (Int, Int)) + @test ptr isa Ptr{Cvoid} + @test ptr != C_NULL + @test ccall(ptr, Int, (Int, Int), 2, 3) == 5 +end + nothing