Skip to content

[nodejs binding] Fix building in latest clang#23146

Merged
fs-eire merged 1 commit into
mainfrom
fs-eire/fix-nodejs-binding-compiling-err
Dec 19, 2024
Merged

[nodejs binding] Fix building in latest clang#23146
fs-eire merged 1 commit into
mainfrom
fs-eire/fix-nodejs-binding-compiling-err

Conversation

@fs-eire
Copy link
Copy Markdown
Contributor

@fs-eire fs-eire commented Dec 18, 2024

Description

This change fixes the build break for Node.js binding on latest AppleClang:

...tensor_helper.cc:65:5 error: integer value -1 is outside of the valid range of values [0,15] for the enumeration type 'napi_typedarray_type' [-Wenum-constexpr-conversion]

Use the underlying type of enum napi_typedarray_type for DATA_TYPE_TYPEDARRAY_MAP to solve this issue.

Because the underlying type is implementation defined (it's int for MSVC and unsigned int for Clang), we use std::underlying_type_t to get the correct type.

@fs-eire fs-eire merged commit 7807350 into main Dec 19, 2024
@fs-eire fs-eire deleted the fs-eire/fix-nodejs-binding-compiling-err branch December 19, 2024 18:23
guschmue pushed a commit that referenced this pull request Dec 20, 2024
### Description

This change fixes the build break for Node.js binding on latest
AppleClang:

```
...tensor_helper.cc:65:5 error: integer value -1 is outside of the valid range of values [0,15] for the enumeration type 'napi_typedarray_type' [-Wenum-constexpr-conversion]

```

Use the underlying type of enum `napi_typedarray_type` for
`DATA_TYPE_TYPEDARRAY_MAP` to solve this issue.

Because the underlying type is implementation defined (it's `int` for
MSVC and `unsigned int` for Clang), we use `std::underlying_type_t` to
get the correct type.
tarekziade pushed a commit to tarekziade/onnxruntime that referenced this pull request Jan 10, 2025
### Description

This change fixes the build break for Node.js binding on latest
AppleClang:

```
...tensor_helper.cc:65:5 error: integer value -1 is outside of the valid range of values [0,15] for the enumeration type 'napi_typedarray_type' [-Wenum-constexpr-conversion]

```

Use the underlying type of enum `napi_typedarray_type` for
`DATA_TYPE_TYPEDARRAY_MAP` to solve this issue.

Because the underlying type is implementation defined (it's `int` for
MSVC and `unsigned int` for Clang), we use `std::underlying_type_t` to
get the correct type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants