mirror of
https://github.com/NixOS/nix
synced 2025-06-29 19:03:16 +02:00
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)()`
This commit is contained in:
parent
5b9cb8b372
commit
01bad63c72
8 changed files with 79 additions and 29 deletions
|
@ -29,7 +29,8 @@ nix_err nix_context_error(nix_c_context * context);
|
|||
* @return NIX_OK if there were no errors.
|
||||
* @see nix_get_string_callback
|
||||
*/
|
||||
nix_err call_nix_get_string_callback(const std::string str, void * callback, void * user_data);
|
||||
nix_err call_nix_get_string_callback(
|
||||
const std::string str, void (*callback)(const char * start, unsigned int n, void * user_data), void * user_data);
|
||||
|
||||
#define NIXC_CATCH_ERRS \
|
||||
catch (...) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue