Compilation fails
brandonros opened this issue · 2 comments
brandonros commented
$ g++ -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Brandons-MacBook-Pro-2:spoof brandonros$ cc spoof.c fline.c -o spoof
Brandons-MacBook-Pro-2:spoof brandonros$ g++ -o ruse ruse.cc
ruse.cc:180:25: error: a space is required between consecutive right angle brackets (use '> >')
vector<vector<word_t>> zero_op;
^~
> >
ruse.cc:199:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto vec : mat)
^
ruse.cc:199:23: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (auto vec : mat)
^
ruse.cc:214:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto k = n & ((1 << ZORDERN) - 1);
^
ruse.cc:258:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto n = init.size();
^
ruse.cc:260:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto last = init.back();
^
ruse.cc:261:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto pos : init)
^
ruse.cc:261:23: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (auto pos : init)
^
ruse.cc:275:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto code = codeword(ones);
^
ruse.cc:280:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto pos : code.ones) {
^
ruse.cc:280:23: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (auto pos : code.ones) {
^
ruse.cc:299:27: error: non-aggregate type 'vector<uintmax_t>' (aka 'vector<unsigned long>') cannot be initialized with an initializer
list
vector<uintmax_t> ones = {0}; // x^0 term is implied
^ ~~~
ruse.cc:472:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto k = stoint<word_t>(tok[1], 0, 0); // Koopman polynomial
^
ruse.cc:475:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto len = stoint<uintmax_t>(tok[5].substr(4)); // dataword length
^
ruse.cc:476:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto res = stoint<word_t>(tok[8].substr(1), 0, 0); // residual CRC
^
ruse.cc:477:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto bits = stoint<int>(tok[9].substr(6)); // number of ones
^
ruse.cc:505:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto crc = &cat.at(k);
^
ruse.cc:534:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto const& ent : cat) {
^
ruse.cc:534:30: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (auto const& ent : cat) {
^
ruse.cc:560:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto beg = mod.tellg();
^
ruse.cc:562:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto end = mod.tellg();
^
ruse.cc:575:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto const& codes = cat.at(koop).codes;
^
ruse.cc:576:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto code = codes.upper_bound(len);
^
ruse.cc:586:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto off = dist(gen);
^
ruse.cc:589:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto const& ones = code->second.ones;
^
ruse.cc:591:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto cur = (off + ones[0]) >> 3;
^
ruse.cc:594:14: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (auto one : ones) {
^
ruse.cc:594:23: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (auto one : ones) {
^
ruse.cc:595:13: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto pos = off + one;
^
ruse.cc:629:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto got = cat.counts();
^
ruse.cc:646:9: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto n = stoint<unsigned>(argv[1]) - 1;
^
29 warnings and 2 errors generated.
madler commented
You need to use the -std=c++11
option for the clang compiler. (I also recommend -O3
.)
brandonros commented
-std=c++11
fixed it