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

Compiler warning (decimal constant) #9

Closed
Stapelzeiger opened this issue Nov 10, 2014 · 3 comments
Closed

Compiler warning (decimal constant) #9

Stapelzeiger opened this issue Nov 10, 2014 · 3 comments

Comments

@Stapelzeiger
Copy link
Contributor

Hi,
I get the following compiler warning when compiling cmp:

src/cmp/cmp.c: In function 'cmp_write_sint':
src/cmp/cmp.c:323:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]

The compiler is arm-none-eabi-gcc version 4.7.4. The warning disappears when I add the suffix LL to the constant:

diff --git a/cmp.c b/cmp.c
index b2a84eb..a2c6e5c 100644
--- a/cmp.c
+++ b/cmp.c
@@ -320,7 +320,7 @@ bool cmp_write_sint(cmp_ctx_t *ctx, int64_t d) {
     return cmp_write_s8(ctx, d);
   if (d >= -32768)
     return cmp_write_s16(ctx, d);
-  if (d >= -2147483648)
+  if (d >= -2147483648LL)
     return cmp_write_s32(ctx, d);

   return cmp_write_s64(ctx, d);
@camgunz
Copy link
Owner

camgunz commented Nov 10, 2014

Hey, thanks for the report.

This warning happens because you're using a 32-bit compiler. It's definitely a bug, but I think I'll solve it by using (-2147483647 - 1) instead of the LL suffix, which promotes the literal to a 64-bit internet unnecessarily.

When I get a chance I'll put the change in, likely later tonight.

@Stapelzeiger
Copy link
Contributor Author

OK, thanks.

@camgunz
Copy link
Owner

camgunz commented Nov 11, 2014

OK I fixed this and put up a new release. Thanks again!

@camgunz camgunz closed this as completed Nov 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants