Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit f3eda5e

Browse files
committed
Update static_assert usage to c_static_assert_msg
1 parent ac329e6 commit f3eda5e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/corefx/System.Globalization.Native/pal_collation.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313

1414
#include "pal_collation.h"
1515

16+
c_static_assert(UCOL_EQUAL == 0, "managed side requires 0 for equal strings");
17+
c_static_assert(UCOL_LESS < 0, "managed side requires less than zero for a < b");
18+
c_static_assert(UCOL_GREATER > 0, "managed side requires greater than zero for a > b");
19+
c_static_assert(USEARCH_DONE == -1, "managed side requires -1 for not found");
20+
1621
const int32_t CompareOptionsIgnoreCase = 0x1;
1722
const int32_t CompareOptionsIgnoreNonSpace = 0x2;
1823
const int32_t CompareOptionsIgnoreSymbols = 0x4;
@@ -475,10 +480,6 @@ CompareString
475480
int32_t GlobalizationNative_CompareString(
476481
SortHandle* pSortHandle, const UChar* lpStr1, int32_t cwStr1Length, const UChar* lpStr2, int32_t cwStr2Length, int32_t options)
477482
{
478-
static_assert(UCOL_EQUAL == 0, "managed side requires 0 for equal strings");
479-
static_assert(UCOL_LESS < 0, "managed side requires less than zero for a < b");
480-
static_assert(UCOL_GREATER > 0, "managed side requires greater than zero for a > b");
481-
482483
UCollationResult result = UCOL_EQUAL;
483484
UErrorCode err = U_ZERO_ERROR;
484485
const UCollator* pColl = GetCollatorFromSortHandle(pSortHandle, options, &err);
@@ -504,8 +505,6 @@ int32_t GlobalizationNative_IndexOf(
504505
int32_t options,
505506
int32_t* pMatchedLength)
506507
{
507-
static_assert(USEARCH_DONE == -1, "managed side requires -1 for not found");
508-
509508
int32_t result = USEARCH_DONE;
510509
UErrorCode err = U_ZERO_ERROR;
511510
const UCollator* pColl = GetCollatorFromSortHandle(pSortHandle, options, &err);
@@ -543,8 +542,6 @@ int32_t GlobalizationNative_LastIndexOf(
543542
int32_t cwSourceLength,
544543
int32_t options)
545544
{
546-
static_assert(USEARCH_DONE == -1, "managed side requires -1 for not found");
547-
548545
int32_t result = USEARCH_DONE;
549546
UErrorCode err = U_ZERO_ERROR;
550547
const UCollator* pColl = GetCollatorFromSortHandle(pSortHandle, options, &err);

src/corefx/System.Globalization.Native/pal_icushim.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static void* libicui18n = NULL;
3131
bool FindICULibs(const char* versionPrefix, char* symbolName, char* symbolVersion)
3232
{
3333
#ifndef OSX_ICU_LIBRARY_PATH
34-
static_assert(false, "The ICU Library path is not defined");
34+
c_static_assert_msg(false, "The ICU Library path is not defined");
3535
#endif // OSX_ICU_LIBRARY_PATH
3636

3737
// Usually OSX_ICU_LIBRARY_PATH is "/usr/lib/libicucore.dylib"
@@ -119,10 +119,10 @@ bool OpenICULibraries(int majorVer, int minorVer, int subVer, const char* versio
119119
char libicuucName[64];
120120
char libicui18nName[64];
121121

122-
static_assert(sizeof("libicuuc.so") + MaxICUVersionStringLength <= sizeof(libicuucName), "The libicuucName is too small");
122+
c_static_assert_msg(sizeof("libicuuc.so") + MaxICUVersionStringLength <= sizeof(libicuucName), "The libicuucName is too small");
123123
GetVersionedLibFileName("libicuuc.so", majorVer, minorVer, subVer, versionPrefix, libicuucName);
124124

125-
static_assert(sizeof("libicui18n.so") + MaxICUVersionStringLength <= sizeof(libicui18nName), "The libicui18nName is too small");
125+
c_static_assert_msg(sizeof("libicui18n.so") + MaxICUVersionStringLength <= sizeof(libicui18nName), "The libicui18nName is too small");
126126
GetVersionedLibFileName("libicui18n.so", majorVer, minorVer, subVer, versionPrefix, libicui18nName);
127127

128128
libicuuc = dlopen(libicuucName, RTLD_LAZY);
@@ -263,7 +263,7 @@ int32_t GlobalizationNative_LoadICU()
263263

264264
// Get pointers to all the ICU functions that are needed
265265
#define PER_FUNCTION_BLOCK(fn, lib) \
266-
static_assert((sizeof(#fn) + MaxICUVersionStringLength + 1) <= sizeof(symbolName), "The symbolName is too small for symbol " #fn); \
266+
c_static_assert_msg((sizeof(#fn) + MaxICUVersionStringLength + 1) <= sizeof(symbolName), "The symbolName is too small for symbol " #fn); \
267267
sprintf(symbolName, #fn "%s", symbolVersion); \
268268
fn##_ptr = (__typeof(fn)*)dlsym(lib, symbolName); \
269269
if (fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol %s from " #lib "\nError: %s\n", symbolName, dlerror()); abort(); }

0 commit comments

Comments
 (0)