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

clar: support compilation without support for wchar_t #108

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions clar.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
#include <sys/types.h>
#include <sys/stat.h>

#if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_WCHAR__)
/*
* uClibc can optionally be built without wchar support, in which case
* the installed <wchar.h> is a stub that only defines the `whar_t`
* type but none of the functions typically declared by it.
*/
Comment on lines +28 to +32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this wchar.h stub does not define wchar_t. It only defines wint_t and WEOF.

Copy link
Member Author

@pks-t pks-t Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, right, thanks for the clarification!

#else
# define CLAR_HAVE_WCHAR
#endif

#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
Expand Down Expand Up @@ -766,6 +776,7 @@ void clar__assert_equal(
}
}
}
#ifdef CLAR_HAVE_WCHAR
else if (!strcmp("%ls", fmt)) {
const wchar_t *wcs1 = va_arg(args, const wchar_t *);
const wchar_t *wcs2 = va_arg(args, const wchar_t *);
Expand Down Expand Up @@ -801,6 +812,7 @@ void clar__assert_equal(
}
}
}
#endif /* CLAR_HAVE_WCHAR */
else if (!strcmp("%"PRIuMAX, fmt) || !strcmp("%"PRIxMAX, fmt)) {
uintmax_t sz1 = va_arg(args, uintmax_t), sz2 = va_arg(args, uintmax_t);
is_equal = (sz1 == sz2);
Expand Down
Loading