Skip to content

Commit ed26c4e

Browse files
committed
Hide ICU C++ APIs from pg_locale.h
The cpluspluscheck script wraps our headers in `extern "C"`. This disables name mangling, which is necessary for the C++ templates in system ICU headers. cpluspluscheck thus fails when the build is configured with ICU (the default). CI worked around this by disabling ICU, but let's make it work so others can run the script. We can specify we only want the C APIs by defining U_SHOW_CPLUSPLUS_API to be 0 in pg_locale.h. Extensions that want the C++ APIs can include ICU headers separately before including PostgreSQL headers. ICU documentation: https://github.com/unicode-org/icu/blob/main/docs/processes/release/tasks/healthy-code.md#test-icu4c-headers Suggested-by: Andres Freund <andres@anarazel.de> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20220323002024.f2g6tivduzrktgfa%40alap3.anarazel.de Discussion: https://postgr.es/m/CANWCAZbgiaz1_0-F4SD%2B%3D-e9onwAnQdBGJbhg94EqUu4Gb7WyA%40mail.gmail.com
1 parent df286a5 commit ed26c4e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

.cirrus.tasks.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,11 @@ task:
938938
# - Don't use ccache, the files are uncacheable, polluting ccache's
939939
# cache
940940
# - Use -fmax-errors, as particularly cpluspluscheck can be very verbose
941-
# - XXX have to disable ICU to avoid errors:
942-
# https://postgr.es/m/20220323002024.f2g6tivduzrktgfa%40alap3.anarazel.de
943941
###
944942
always:
945943
headers_headerscheck_script: |
946944
time ./configure \
947945
${LINUX_CONFIGURE_FEATURES} \
948-
--without-icu \
949946
--quiet \
950947
CC="gcc" CXX"=g++" CLANG="clang-16"
951948
make -s -j${BUILD_JOBS} clean

src/include/utils/pg_locale.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include "mb/pg_wchar.h"
1616

1717
#ifdef USE_ICU
18+
/* only include the C APIs, to avoid errors in cpluspluscheck */
19+
#undef U_SHOW_CPLUSPLUS_API
20+
#define U_SHOW_CPLUSPLUS_API 0
1821
#include <unicode/ucol.h>
1922
#endif
2023

0 commit comments

Comments
 (0)