Skip to content
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
8 changes: 6 additions & 2 deletions bindgen-tests/tests/expectations/tests/infinite-macro.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions bindgen-tests/tests/headers/infinite-macro.h

This file was deleted.

7 changes: 7 additions & 0 deletions bindgen-tests/tests/headers/infinite-macro.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#define INFINITY (1.0f/0.0f)
#define NEG_INFINITY (-1.0f/0.0f)
#define NAN (0.0f/0.0f)

static const float F32_INFINITY = 1.0f / 0.0f;
static const float F32_NEG_INFINITY = -1.0f / 0.0f;
static const float F32_NAN = 0.0f / 0.0f;
6 changes: 3 additions & 3 deletions bindgen/codegen/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,14 @@ pub(crate) mod ast_ty {
}

if f.is_nan() {
return Ok(quote! { f64::NAN });
return Ok(quote! { f64::NAN as _ });
}

if f.is_infinite() {
let tokens = if f.is_sign_positive() {
quote! { f64::INFINITY }
quote! { f64::INFINITY as _ }
} else {
quote! { f64::NEG_INFINITY }
quote! { f64::NEG_INFINITY as _ }
};
return Ok(tokens);
}
Expand Down