Quote:
Originally Posted by dander062
I had been trying -Werror -Wall -Wextra
Thank you.
-Wconversion is what I was looking for. Just too bad it waits until 80.01 instead of 80.00.
I will have to get better at proofreading.
|
I am working (was aided by this forum) on what I call strict C++ types. At the moment:
Code:
sergei@amdam2:~/junk/c++_work/strict_types> cat -n main.cxx
1 #include "Strict_types.hxx"
2 #include <iostream>
3
4
5 int main()
6 {
7 Strict_unsigned uu = 80.0;
8 // Strict_unsigned u = 1; // error: ?Strict_unsigned::Strict_unsigned(int)? is private
9 Strict_unsigned u1 = 1u;
10
11 std::cerr << "sizeof(Strict_unsigned)=" << sizeof(Strict_unsigned) << "\n";
12
13 std::cerr << "u1=" << u1.get() << "\n";
14
15 Strict_unsigned u2 = 2u;
16
17 u1 = u1 << u2; std::cerr << "u1=" << u1.get() << "\n";
18
19 u1 = 16u; std::cerr << "u1=" << u1.get() << "\n";
20
21 u1 >>= 2u; std::cerr << "u1=" << u1.get() << "\n";
22
23 u1 = u1 << 2u; std::cerr << "u1=" << u1.get() << "\n";
24
25 u1 *= (Strict_unsigned)2u; std::cerr << "u1=" << u1.get() << "\n";
26
27 return 0;
28 }
sergei@amdam2:~/junk/c++_work/strict_types> ~/AFSWD/install/gcc-4.5.4/binsh/g++ -Wall -Wextra main.cxx -o main
Strict_types.hxx: In function ‘int main()’:
Strict_types.hxx:2882:5: error: ‘Strict_unsigned::Strict_unsigned(double)’ is private
main.cxx:7:24: error: within this context
sergei@amdam2:~/junk/c++_work/strict_types>
.
I.e. my goal is to be able to avoid exactly errors of such kind.