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

feat: added _Nonnull and _Nullable attributes to mujoco.h #1038

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions include/mujoco/mjmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,21 @@
}
#endif

//-------------------------- nullability check
//----------------------------------------------------

#ifdef __clang__
#define NONNULL_ARG _Nonnull
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Please indent the #ifdef bodies.
  2. I don't think we need NONNULL_ARG. Clang supports the GCC syntax.
  3. Due to 2, let's rename NONNULL_FUNC -> NONNULL and NULLABLE_ARG -> NULLABLE.
  4. I think this whole block belongs in mujoco.h and requires #undefs at the end

Copy link
Author

Choose a reason for hiding this comment

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

Will do it and also I will restore the other unintentional changes that happened.

#define NULLABLE_ARG _Nullable
#define NONNULL_FUNC(...) /* NOT SUPPORTED */
#elif defined(__GNUC__)
#define NONNULL_ARG /* NOT SUPPORTED */
#define NULLABLE_ARG /* NOT SUPPORTED */
#define NONNULL_FUNC(...) __attribute__((nonnull(__VA_ARGS__)))
#else
#define NONNULL_ARG /* NOT SUPPORTED */
#define NULLABLE_ARG /* NOT SUPPORTED */
#define NONNULL_FUNC(...) /* NOT SUPPORTED */
#endif

#endif // MUJOCO_MJMACRO_H_
Loading