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

Avoid compilation warnings #103

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ GCCFLAGS = $(C_INCLUDES) \
-fdata-sections \
-fverbose-asm \
-Wextra \
-Wunused-parameter \
-Wfloat-equal
-Wunused-parameter

CFLAGS = $(GCCFLAGS) \
-Wunsuffixed-float-constants \
Expand Down
2 changes: 1 addition & 1 deletion printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ static size_t _etoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, d
// output the exponential symbol
out((flags & FLAGS_UPPERCASE) ? 'E' : 'e', buffer, idx++, maxlen);
// output the exponent value
idx = _ntoa_long(out, buffer, idx, maxlen, (expval < 0) ? -expval : expval, expval < 0, 10, 0, minwidth-1, FLAGS_ZEROPAD | FLAGS_PLUS);
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long) ((expval < 0) ? -expval : expval), expval < 0, 10, 0, minwidth-1, FLAGS_ZEROPAD | FLAGS_PLUS);
// might need to right-pad spaces
if (flags & FLAGS_LEFT) {
while (idx - start_idx < width) out(' ', buffer, idx++, maxlen);
Expand Down
8 changes: 4 additions & 4 deletions test/test_suite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ TEST_CASE("float", "[]" ) {
test::sprintf(buffer, "%8f", INFINITY);
REQUIRE(!strcmp(buffer, " inf"));

test::sprintf(buffer, "%-8f", -INFINITY);
test::sprintf(buffer, "%-8f", (double) -INFINITY);
REQUIRE(!strcmp(buffer, "-inf "));

#ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL
Expand Down Expand Up @@ -1217,7 +1217,7 @@ TEST_CASE("float", "[]" ) {
std::stringstream str;
str.precision(5);
for (float i = -100000; i < 100000; i += 1) {
test::sprintf(buffer, "%.5f", i / 10000);
test::sprintf(buffer, "%.5f", (double)(i / 10000));
str.str("");
str << std::fixed << i / 10000;
fail = fail || !!strcmp(buffer, str.str().c_str());
Expand All @@ -1228,8 +1228,8 @@ TEST_CASE("float", "[]" ) {
#ifndef PRINTF_DISABLE_SUPPORT_EXPONENTIAL
// brute force exp
str.setf(std::ios::scientific, std::ios::floatfield);
for (float i = -1e20; i < 1e20; i += 1e15) {
test::sprintf(buffer, "%.5f", i);
for (float i = -1e20; i < (float) 1e20; i += (float) 1e15) {
test::sprintf(buffer, "%.5f", (double) i);
str.str("");
str << i;
fail = fail || !!strcmp(buffer, str.str().c_str());
Expand Down