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

ICU-20601 Wrap public ICU API compound macros in do { } while. #759

Merged
merged 1 commit into from Aug 15, 2019

Conversation

@roubert
Copy link
Member

commented Aug 15, 2019

https://unicode-org.atlassian.net/browse/ICU-20601

This is the normal way of making compound macros behave like statements
and allowing macro invocations that look like function calls to work
just like if they were function calls.

Before ICU 65, function like multi statement ICU macros were just
defined as series of statements wrapped in { } blocks and the caller
could choose to either treat them as if they were actual functions and
end the invocation with a trailing ; creating an empty statement after
the block or else omit this trailing ; using the knowledge that the
macro would expand to { }.

To continue supporting code that depends on that old behaviour, on being
able to omit the trailing ; when invoking one of these macros, the new
surrounding do { } while is done through preprocessor defines that can
easily be overridden at compile time, when needed.

@roubert roubert requested a review from markusicu Aug 15, 2019

@markusicu
Copy link
Contributor

left a comment

other than naming & grammar, lgtm

icu4c/source/common/unicode/umachine.h Outdated Show resolved Hide resolved
icu4c/source/common/unicode/umachine.h Outdated Show resolved Hide resolved
ICU-20601 Wrap public ICU API compound macros in do { } while.
This is the normal way of making compound macros behave like statements
and allowing macro invocations that look like function calls to work
just like if they were function calls.

Before ICU 65, function-like, multi-statement ICU macros were just
defined as series of statements wrapped in { } blocks and the caller
could choose to either treat them as if they were actual functions and
end the invocation with a trailing ; creating an empty statement after
the block or else omit this trailing ; using the knowledge that the
macro would expand to { }.

To continue supporting code that depends on that old behaviour, on being
able to omit the trailing ; when invoking one of these macros, the new
surrounding do { } while is done through preprocessor defines that can
easily be overridden at compile time, when needed.

@roubert roubert force-pushed the roubert:20601 branch from fc3241d to 4e1c79d Aug 15, 2019

@jira-pull-request-webhook

This comment has been minimized.

Copy link

commented Aug 15, 2019

Notice: the branch changed across the force-push!

  • icu4c/source/common/unicode/ucptrie.h is different
  • icu4c/source/common/unicode/umachine.h is different
  • icu4c/source/common/unicode/utext.h is different
  • icu4c/source/common/unicode/utf_old.h is different
  • icu4c/source/common/unicode/utf16.h is different
  • icu4c/source/common/unicode/utf8.h is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@markusicu
Copy link
Contributor

left a comment

lgtm

@roubert roubert merged commit 480bec3 into unicode-org:master Aug 15, 2019

16 checks passed

Azure CI Builds Build #20190815.6 succeeded
Details
Azure CI Builds (C: Linux Clang (Ubuntu 16.04)) C: Linux Clang (Ubuntu 16.04) succeeded
Details
Azure CI Builds (C: Linux Clang DataFilter (Ubuntu 16.04)) C: Linux Clang DataFilter (Ubuntu 16.04) succeeded
Details
Azure CI Builds (C: Linux Clang WarningsAsErrors (Ubuntu 16.04)) C: Linux Clang WarningsAsErrors (Ubuntu 16.04) succeeded
Details
Azure CI Builds (C: MSVC 32-bit Debug (VS 2017)) C: MSVC 32-bit Debug (VS 2017) succeeded
Details
Azure CI Builds (C: MSVC 64-bit Release (VS 2015)) C: MSVC 64-bit Release (VS 2015) succeeded
Details
Azure CI Builds (C: MSVC 64-bit Release (VS 2017)) C: MSVC 64-bit Release (VS 2017) succeeded
Details
Azure CI Builds (C: MSVC 64-bit Release DataFilter (VS 2017)) C: MSVC 64-bit Release DataFilter (VS 2017) succeeded
Details
Azure CI Builds (C: MSVC x64 ARM32 ARM64 Release (VS 2017)) C: MSVC x64 ARM32 ARM64 Release (VS 2017) succeeded
Details
Azure CI Builds (C: MSYS2 GCC x86_64 Release) C: MSYS2 GCC x86_64 Release succeeded
Details
Azure CI Builds (J: Linux OpenJDK (Ubuntu 16.04)) J: Linux OpenJDK (Ubuntu 16.04) succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jira-ticket ICU-20601 “Statement macros should be wrapped in do{}while(0)”
Details
license/cla Contributor License Agreement is signed.
Details
single-commit This PR includes exactly 1 commit!

@roubert roubert deleted the roubert:20601 branch Aug 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.