backward-cpp icon indicating copy to clipboard operation
backward-cpp copied to clipboard

Issues with Pedantic compiling

Open xMAC94x opened this issue 9 years ago • 2 comments

Hey, while installing the library in my project i got 2 compiler warnings due to my pedantic settings ("/W4" under Windows, "-Wall -Wextra -Werror -Wno-long-long -Wpedantic" under linux).

It would be cool if you could fix them in the original code, this is the diff i used to fix both errors, however you should have a brief look the solution because i just started working with c++:

1st Error: compiler warning because of possible lost of data when converting size_t to unsigned 2nd Error: isspace returns an int, but the function should return a bool

 backward.hpp
@@ -435,7 +435,7 @@ struct Trace {
 		addr(0), idx(0) {}
 
 	explicit Trace(void* addr, size_t idx):
- 		addr(addr), idx(idx) {}
+ 		addr(addr), idx(unsigned(idx)) {}
 };
 
 struct ResolvedTrace: public Trace {
@@ -1520,7 +1520,7 @@ public:
 		// What a good boy am I.
 		struct isspace {
 			bool operator()(char c) {
- 				return std::isspace(c);
+ 				return std::isspace(c) != 0;
 			}
 		};

xMAC94x avatar Jan 09 '17 01:01 xMAC94x

We should probably change the type of the attribute idx to size_t.

bombela avatar Jan 09 '17 03:01 bombela

We should probably change the type of the attribute idx to size_t.

And compile with warnings==errors. There's some more warnings in https://github.com/bombela/backward-cpp/blob/5ffb2c879ebdbea3bdb8477c671e32b1c984beaa/backward.hpp#L3618 ff (I suppose, I don't have the git version) due to the conversion from size_t to DWORD.

HorstBaerbel avatar Feb 08 '22 10:02 HorstBaerbel