Commit graph

7 commits

Author SHA1 Message Date
tomberek
96a2ddab27
Merge pull request #10910 from hercules-ci/c-api-nix_clear_err
C API: `nix_clear_err`
2024-08-26 10:50:26 -04:00
Robert Hensing
83d585b423 C API: Make nix_err an enum
This generally gives a better experience with bindings generators,
possibly other tooling.

A possible risk is that some generators may not represent unknown
codes correctly.
Rust bindgen by default generates suitable code:
  * a type alias nix_err = c_int
  * individual constants for the known enum values
It does _not_ generate a closed type that can only hold the values
that were known at code generation time.

If this proves to be a problem, we could instead split the type:

`typedef int nix_err;` for return values
`enum nix_known_err` for code generation.

This would complicate the interface, so let's not do it unless it
is shown to be needed.
2024-07-17 16:54:30 +02:00
Robert Hensing
2dc7598779 C API: Add nix_clear_err 2024-06-14 16:30:34 +02:00
José Luis Lafuente
774e7213e8
C API: Use nix_get_string_callback typedef 2024-04-15 12:05:57 +02:00
José Luis Lafuente
01bad63c72
C API: Safer function pointer casting
See https://github.com/NixOS/nix/pull/8699#discussion_r1554312181

Casting a function pointer to `void*` is undefined behavior in the C
spec, since there are platforms with different sizes for these two kinds
of pointers. A safe alternative might be `void (*callback)()`
2024-04-12 21:41:15 +02:00
José Luis Lafuente
2bb609bce2
C API: rename nix_observe_string -> nix_get_string_callback 2024-03-29 10:01:16 +01:00
José Luis Lafuente
c57de60522
C API: Keep the structure flat
See https://github.com/NixOS/nix/pull/10329
2024-03-28 19:00:04 +01:00
Renamed from src/libutil/c/nix_api_util.h (Browse further)