Skip to content

Commit

Permalink
ICU-22576 Use standard alignof() with modern C.
Browse files Browse the repository at this point in the history
  • Loading branch information
roubert committed Dec 14, 2023
1 parent 1bc059e commit e112f89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .ci-builds/.azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
displayName: 'Build only (WarningsAsErrors)'
env:
CC: clang-16
CPPFLAGS: '-Werror -Wno-strict-prototypes -Wno-gnu-offsetof-extensions -Wall -Wextra -Wextra-semi -Wundef -Wnon-virtual-dtor -Wsuggest-override'
CPPFLAGS: '-Werror -Wno-strict-prototypes -Wall -Wextra -Wextra-semi -Wundef -Wnon-virtual-dtor -Wsuggest-override'
CXX: clang++-16
#-------------------------------------------------------------------------
- job: ICU4C_Clang16_Cpp20_Ubuntu_2004
Expand All @@ -188,7 +188,7 @@ jobs:
displayName: 'Build and Test'
env:
CC: clang-16
CPPFLAGS: '-Werror -Wno-strict-prototypes -Wno-gnu-offsetof-extensions'
CPPFLAGS: '-Werror -Wno-strict-prototypes'
CXX: clang++-16
CXXFLAGS: '-std=c++20'
#-------------------------------------------------------------------------
Expand All @@ -213,7 +213,7 @@ jobs:
displayName: 'Build and Test'
env:
CC: clang-16
CPPFLAGS: '-Werror -Wno-strict-prototypes -Wno-gnu-offsetof-extensions'
CPPFLAGS: '-Werror -Wno-strict-prototypes'
CXX: clang++-16
CXXFLAGS: '-std=c++20 -stdlib=libc++'
#-------------------------------------------------------------------------
Expand Down
9 changes: 6 additions & 3 deletions icu4c/source/test/cintltst/ccapitst.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
#define MAX_FILE_LEN 1024*20
#define UCS_FILE_NAME_SIZE 512

/* Similar to C++ alignof(type) */
#define ALIGNOF(type) offsetof (struct { char c; type member; }, member)
#if __STDC_VERSION__ < 201112
# define alignof(type) offsetof (struct { char c; type member; }, member)
#elif __STDC_VERSION__ < 202311
# include <stdalign.h>
#endif

/*returns an action other than the one provided*/
#if !UCONFIG_NO_LEGACY_CONVERSION
Expand Down Expand Up @@ -1837,7 +1840,7 @@ static void TestConvertSafeClone()
/* close the original immediately to make sure that the clone works by itself */
ucnv_close(cnv);

if( actualSizes[idx] <= (bufferSizes[j] - (int32_t)ALIGNOF(UConverter)) &&
if( actualSizes[idx] <= (bufferSizes[j] - (int32_t)alignof(UConverter)) &&
err == U_SAFECLONE_ALLOCATED_WARNING
) {
log_err("ucnv_safeClone(%s) did a heap clone although the buffer was large enough\n", names[idx]);
Expand Down

0 comments on commit e112f89

Please sign in to comment.