-
Notifications
You must be signed in to change notification settings - Fork 525
Enable build warnings/errors on Windows #831
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
#ifndef MATHEXTENSIONS_H | ||
#define MATHEXTENSIONS_H | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
/** | ||
|
@@ -28,12 +29,22 @@ | |
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) | ||
|
||
/** Evaluates to true if a + b would overflow for int32 */ | ||
#define ADD_INT32S_OVERFLOWS(a, b) \ | ||
((a) > 0 ? (INT32_MAX - (a) < (b)) : (INT32_MIN - (a) > (b))) | ||
static inline bool ADD_INT32S_OVERFLOWS(int32_t a, int32_t b) { | ||
if (a > 0) { | ||
return INT32_MAX - a < b; | ||
} else { | ||
return INT32_MIN - a > b; | ||
} | ||
} | ||
Comment on lines
+32
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of these two changes? Do they actually affect the compiler warnings in some way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's for suppressing the following warnings (that are listed in the description): src/h3lib/lib/coodijk.c:
src/apps/testapps/testMathExtensionsInternal.c:
It seems that MSVC can't process |
||
|
||
/** Evaluates to true if a - b would overflow for int32 */ | ||
#define SUB_INT32S_OVERFLOWS(a, b) \ | ||
((a) >= 0 ? (INT32_MIN + (a) >= (b)) : (INT32_MAX + (a) + 1 < (b))) | ||
static inline bool SUB_INT32S_OVERFLOWS(int32_t a, int32_t b) { | ||
if (a >= 0) { | ||
return INT32_MIN + a >= b; | ||
} else { | ||
return INT32_MAX + a + 1 < b; | ||
} | ||
} | ||
|
||
// Internal functions | ||
int64_t _ipow(int64_t base, int64_t exp); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong,
/W2
is a MSVC flag and you should checkMSVC
instead. MSVC isn't the only Windows compiler available.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting! Would you mind filing an issue for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry! I've opened an issue for this: #980
I'll open a PR too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#981