Skip to content

Comments

Replaced DEBUG macro with NDEBUG#5113

Merged
piaskowyk merged 5 commits intomainfrom
replace-debug-with-ndebug
Oct 16, 2023
Merged

Replaced DEBUG macro with NDEBUG#5113
piaskowyk merged 5 commits intomainfrom
replace-debug-with-ndebug

Conversation

@michalmaka
Copy link
Contributor

@michalmaka michalmaka commented Sep 21, 2023

Summary

During working on integration of some other library @t0ms0n00 and I found out that our definition od DEBUG preprocessor macro was causing compilation error when we compile 3rd pary library. Such definition should not be used and better way is to use standard way of NDEBUG definition which is defined in release builds by default.

The problem was due to 3rd party having an enum with one entry named DEBUG which was replaced by preprocessor macro to 1 and caused compilation error.

We should use NDEBUG or name our preprocessor macro differently like REANIMATED_DEBUG.

NDEBUG is mentioned several times in C++ standard https://isocpp.org/files/papers/N4860.pdf

Test plan

Check if compilation is successful

@michalmaka michalmaka force-pushed the replace-debug-with-ndebug branch from 5e610f7 to 6305042 Compare October 9, 2023 09:28
@tomekzaw
Copy link
Member

tomekzaw commented Oct 9, 2023

Added CI check that disallows #if DEBUG and #ifdef DEBUG in common/Cpp, android/src/main/cpp and apple/. Should we also forbid #elif DEBUG? 🤔

@piaskowyk piaskowyk added this pull request to the merge queue Oct 16, 2023
Merged via the queue into main with commit 15418e6 Oct 16, 2023
@piaskowyk piaskowyk deleted the replace-debug-with-ndebug branch October 16, 2023 13:11
github-merge-queue bot pushed a commit that referenced this pull request Nov 20, 2023
## Summary

This PR aims to fix the issue when Release builds would fail on Paper on
iOS.
The reason this regression happened is #5113.

XCode ships by default to new projects `DEBUG` macro for Debug
Configuration. Due to some issues (#4902) we decided to switch over to
`NDEBUG` macro. However, the `NDEBUG` is not provided by XCode out of
the box. Incidentally, it's provided by React Native which puts its
install script into project's Podfile - however, [only in
Fabric](facebook/react-native@421df9f).
What is more, some time ago React Native made it so `PRODUCTION=1 pod
install` is [no longer a necessary
step](facebook/react-native@93fdcba)
to make a release build, therefore we cannot rely on it. Until React
Native defines `NDEBUG` for Paper too we have to detect, based on
available options, whether we potentially have a Release build and this
pull request does this.

Thanks to
#5383 we
finally figures out how to do it the most agreeable way. We hardcode
that for a build config named `Release` NDEBUG=1 will be set. If the
user uses some custom release build config e.g. "MyRelease", NDEBUG=1
will not be set - in this situation we'll require the user to use
`PRODUCTION=1`.

## Test plan

Run all example apps (except TVOS cause I couldn't make it cooperate
with me, and Web) on both iOS and Android in both Release and Debug and
see if they work properly (e.g. add a throw in #ifndef fragment).
Latropos pushed a commit that referenced this pull request Nov 24, 2023
## Summary

This PR aims to fix the issue when Release builds would fail on Paper on
iOS.
The reason this regression happened is #5113.

XCode ships by default to new projects `DEBUG` macro for Debug
Configuration. Due to some issues (#4902) we decided to switch over to
`NDEBUG` macro. However, the `NDEBUG` is not provided by XCode out of
the box. Incidentally, it's provided by React Native which puts its
install script into project's Podfile - however, [only in
Fabric](facebook/react-native@421df9f).
What is more, some time ago React Native made it so `PRODUCTION=1 pod
install` is [no longer a necessary
step](facebook/react-native@93fdcba)
to make a release build, therefore we cannot rely on it. Until React
Native defines `NDEBUG` for Paper too we have to detect, based on
available options, whether we potentially have a Release build and this
pull request does this.

Thanks to
#5383 we
finally figures out how to do it the most agreeable way. We hardcode
that for a build config named `Release` NDEBUG=1 will be set. If the
user uses some custom release build config e.g. "MyRelease", NDEBUG=1
will not be set - in this situation we'll require the user to use
`PRODUCTION=1`.

## Test plan

Run all example apps (except TVOS cause I couldn't make it cooperate
with me, and Web) on both iOS and Android in both Release and Debug and
see if they work properly (e.g. add a throw in #ifndef fragment).
Latropos pushed a commit that referenced this pull request Dec 12, 2023
## Summary

This PR aims to fix the issue when Release builds would fail on Paper on
iOS.
The reason this regression happened is #5113.

XCode ships by default to new projects `DEBUG` macro for Debug
Configuration. Due to some issues (#4902) we decided to switch over to
`NDEBUG` macro. However, the `NDEBUG` is not provided by XCode out of
the box. Incidentally, it's provided by React Native which puts its
install script into project's Podfile - however, [only in
Fabric](facebook/react-native@421df9f).
What is more, some time ago React Native made it so `PRODUCTION=1 pod
install` is [no longer a necessary
step](facebook/react-native@93fdcba)
to make a release build, therefore we cannot rely on it. Until React
Native defines `NDEBUG` for Paper too we have to detect, based on
available options, whether we potentially have a Release build and this
pull request does this.

Thanks to
#5383 we
finally figures out how to do it the most agreeable way. We hardcode
that for a build config named `Release` NDEBUG=1 will be set. If the
user uses some custom release build config e.g. "MyRelease", NDEBUG=1
will not be set - in this situation we'll require the user to use
`PRODUCTION=1`.

## Test plan

Run all example apps (except TVOS cause I couldn't make it cooperate
with me, and Web) on both iOS and Android in both Release and Debug and
see if they work properly (e.g. add a throw in #ifndef fragment).
Latropos pushed a commit that referenced this pull request Dec 18, 2023
This PR aims to fix the issue when Release builds would fail on Paper on
iOS.
The reason this regression happened is #5113.

XCode ships by default to new projects `DEBUG` macro for Debug
Configuration. Due to some issues (#4902) we decided to switch over to
`NDEBUG` macro. However, the `NDEBUG` is not provided by XCode out of
the box. Incidentally, it's provided by React Native which puts its
install script into project's Podfile - however, [only in
Fabric](facebook/react-native@421df9f).
What is more, some time ago React Native made it so `PRODUCTION=1 pod
install` is [no longer a necessary
step](facebook/react-native@93fdcba)
to make a release build, therefore we cannot rely on it. Until React
Native defines `NDEBUG` for Paper too we have to detect, based on
available options, whether we potentially have a Release build and this
pull request does this.

Thanks to
#5383 we
finally figures out how to do it the most agreeable way. We hardcode
that for a build config named `Release` NDEBUG=1 will be set. If the
user uses some custom release build config e.g. "MyRelease", NDEBUG=1
will not be set - in this situation we'll require the user to use
`PRODUCTION=1`.

Run all example apps (except TVOS cause I couldn't make it cooperate
with me, and Web) on both iOS and Android in both Release and Debug and
see if they work properly (e.g. add a throw in #ifndef fragment).
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