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

Implement lib_version() #240

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions docs/src/_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ CurrentModule = ZMQ
This documents notable changes in ZMQ.jl. The format is based on [Keep a
Changelog](https://keepachangelog.com).

## Unreleased

### Added

- [`lib_version()`](@ref) to get the libzmq version ([#240]).

## [v1.2.5] - 2024-05-28

Expand Down
8 changes: 8 additions & 0 deletions docs/src/reference.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
```@meta
CurrentModule = ZMQ
```

# Reference

```@docs
lib_version
```

## Sockets

The ZMQ Socket type:
Expand Down
16 changes: 13 additions & 3 deletions src/ZMQ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,23 @@ include("sockopts.jl")
include("message.jl")
include("comm.jl")

function __init__()
"""
lib_version()

Get the libzmq version number.
"""
function lib_version()
major = Ref{Cint}()
minor = Ref{Cint}()
patch = Ref{Cint}()
ccall((:zmq_version, libzmq), Cvoid, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), major, minor, patch)
global version = VersionNumber(major[], minor[], patch[])
if version < v"3"
return VersionNumber(major[], minor[], patch[])
end

const version = lib_version()

function __init__()
if lib_version() < v"3"
error("ZMQ version $version < 3 is not supported")
end
atexit() do
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ end
@test !isopen(leaked_ctx)
end

@testset "Utilities" begin
@test ZMQ.lib_version() isa VersionNumber
end

@testset "Aqua.jl" begin
Aqua.test_all(ZMQ)
end
Loading