Skip to content

Commit

Permalink
Avoid conflict with the macro CHAR_WIDTH
Browse files Browse the repository at this point in the history
It looks like CHAR_WIDTH is a macro in glibc. See
https://sourceware.org/ml/libc-alpha/2016-09/msg00225.html
  • Loading branch information
aroig authored and vitaut committed Nov 25, 2017
1 parent f03a35a commit 0e91437
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1983,21 +1983,21 @@ class arg_formatter_base {
using pointer_type = typename basic_writer<Char>::pointer_type;
Char fill = internal::char_traits<Char>::cast(specs_.fill());
pointer_type out = pointer_type();
const unsigned CHAR_WIDTH = 1;
if (specs_.width_ > CHAR_WIDTH) {
const unsigned character_width = 1;
if (specs_.width_ > character_width) {
out = writer_.grow_buffer(specs_.width_);
if (specs_.align_ == ALIGN_RIGHT) {
std::uninitialized_fill_n(out, specs_.width_ - CHAR_WIDTH, fill);
out += specs_.width_ - CHAR_WIDTH;
std::uninitialized_fill_n(out, specs_.width_ - character_width, fill);
out += specs_.width_ - character_width;
} else if (specs_.align_ == ALIGN_CENTER) {
out = writer_.fill_padding(out, specs_.width_,
internal::const_check(CHAR_WIDTH), fill);
internal::const_check(character_width), fill);
} else {
std::uninitialized_fill_n(out + CHAR_WIDTH,
specs_.width_ - CHAR_WIDTH, fill);
std::uninitialized_fill_n(out + character_width,
specs_.width_ - character_width, fill);
}
} else {
out = writer_.grow_buffer(CHAR_WIDTH);
out = writer_.grow_buffer(character_width);
}
*out = internal::char_traits<Char>::cast(value);
}
Expand Down

0 comments on commit 0e91437

Please sign in to comment.