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

doc: correct struct definition #969

Merged
merged 1 commit into from
Apr 16, 2021

Conversation

RaisinTen
Copy link
Contributor

No description provided.

@@ -25,13 +25,12 @@ information is stored in the `napi_node_version` structure that is defined as
shown below:

```cpp
using napi_node_version =
struct {
using napi_node_version = struct {
Copy link
Member

@legendecas legendecas Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the intention of this code block is just showing how struct napi_node_version is defined in node_api_types.h, but not how users should define the types. As the type struct napi_node_version is defined as followings:

typedef struct {
  uint32_t major;
  uint32_t minor;
  uint32_t patch;
  const char* release;
} napi_node_version;

I believe the best way to do this here is to keep aligned with node_api_types.h or just remove the code block to prevent confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@legendecas I think it would be better to keep the code block. I have a PR open to replace the typedefs with usings in main repo that also changes this part in the file: https://github.com/nodejs/node/pull/38228/files#diff-9751c3fa7589557e1988160cbf907aa233c3cff86e1320fbc634d80394c918edR37-R42. Maybe we should wait for a confirmation on that PR before changing this?

Copy link
Member

@legendecas legendecas Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I really mean is that header files like node_api.h, js_native_api.h, and so on are C headers but not C++ headers. We are not intended to use C++ features like using declarations in them. It's by design so that pure C programs can also using node-api too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@legendecas Thanks for letting me know that it's a C header. Updated the PR. PTAL.

@RaisinTen RaisinTen force-pushed the doc/remove-unnecessary-struct-name branch from ad9cfb1 to 2c4418d Compare April 15, 2021 16:02
@RaisinTen RaisinTen changed the title doc: remove unnecessary struct name doc: correct struct definition Apr 15, 2021
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mhdawson mhdawson merged commit 1c9d528 into nodejs:main Apr 16, 2021
@RaisinTen RaisinTen deleted the doc/remove-unnecessary-struct-name branch April 17, 2021 13:47
JckXia pushed a commit to JckXia/node-addon-api that referenced this pull request Apr 20, 2021
deepakrkris pushed a commit to deepakrkris/node-addon-api that referenced this pull request Sep 23, 2021
deepakrkris pushed a commit to deepakrkris/node-addon-api that referenced this pull request Oct 15, 2021
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.

3 participants