Skip to content

Commit 2483461

Browse files
committed
Try to fix 32bit build, again.
Suppress more clang warnings. Replaced deprecated std::unary_function and std::binary_function.
1 parent 87d5494 commit 2483461

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

cpp_cli/jdepp-app.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static void parse_library_options(int &i, const int argc, char **argv,
1919
lib_args.push_back(argv[i + lib_args.size()]);
2020
}
2121

22-
printf("libsize %d\n", lib_args.size());
22+
//printf("libsize %d\n", lib_args.size());
2323
i += lib_args.size();
2424
lib_args.push_back(nullptr);
2525
} else {

jdepp/classify.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define SHIFT_LEFT_UNSIGNED_USES_SHL (((unsigned int)0xffffffff >> 1) == 0x7fffffff)
1919

2020
namespace pecco {
21+
2122
// (a slightly) secure conversion from string to numerical
2223
template <typename T> T strton (const char* s, char** error) {
2324
const int64_t ret = static_cast <int64_t> (std::strtoll (s, error, 10));
@@ -35,6 +36,8 @@ namespace pecco {
3536
{ return static_cast <float> (std::strtod (s, error)); }
3637
#endif
3738

39+
// On 32bit platform, size_t == uint
40+
#if (SIZE_MAX > (1 << 32))
3841
template <> ny::uint strton <ny::uint> (const char* s, char** error) {
3942
int64_t ret = 0;
4043
char* p = const_cast <char*> (s);
@@ -47,10 +50,8 @@ namespace pecco {
4750
return static_cast <ny::uint> (ret);
4851
}
4952

50-
// On 32bit platform, size_t == uint
51-
#if (SIZE_MAX > (1 << 32))
52-
template size_t strton (const char*, char**);
5353
#endif
54+
template size_t strton (const char*, char**);
5455

5556
template uint8_t strton (const char*, char**);
5657
template algo_t strton (const char*, char**);
@@ -301,7 +302,7 @@ namespace pecco {
301302
it != fst_key.end (); ++it)
302303
if ((*it)->leaf) fst_leaf.insert (*it);
303304
if (_opt.verbose > 0)
304-
std::fprintf (stderr, " # leaf: %ld\n", fst_leaf.size ());
305+
std::fprintf (stderr, " # leaf: %ld\n", long(fst_leaf.size ()));
305306
std::vector <const char *> str;
306307
std::vector <size_t> len;
307308
std::vector <int> val;

jdepp/pa.h

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ namespace opal {
12981298
#endif
12991299
train1 (pool);
13001300
std::fprintf (stderr, "\r%s%s iter=%-3u #ex=%-8ld ",
1301-
_opt.average ? "Avg " : "", algo[_opt.algo], i, _nex);
1301+
_opt.average ? "Avg " : "", algo[_opt.algo], i, long(_nex));
13021302
if (_opt.kernel == POLY) std::fprintf (stderr, "#SV=%u; ", _nsv);
13031303
if (std::strcmp (tfn, "") != 0) {
13041304
Model m (_opt);
@@ -1702,6 +1702,7 @@ namespace opal {
17021702
typedef ss_t::const_iterator ss_it;
17031703
typedef std::vector <ss_t> f2ss_t;
17041704
#if defined (USE_HASH) || defined (USE_TR1_HASH)
1705+
#if 0 // std::unary_function and std::binary_function is deprecated in C++11 and removed in C++17
17051706
struct hash_sv : std::unary_function <const sv_t*, size_t> {
17061707
result_type operator () (argument_type f) const
17071708
{ return std::accumulate (f->begin (), f->end (), FNV_BASIS, inc_fnv ()); }
@@ -1712,12 +1713,26 @@ namespace opal {
17121713
std::equal (a->begin (), a->end (), b->begin ());
17131714
}
17141715
};
1716+
#else
1717+
struct hash_sv {
1718+
inline size_t operator()(const sv_t *) const {
1719+
return std::accumulate (f->begin (), f->end (), FNV_BASIS, inc_fnv ()); }
1720+
}
1721+
};
1722+
struct eq_sv {
1723+
bool operator () (const sv_t *a, const sv_t *b) const {
1724+
return a->getSize () == b->getSize () &&
1725+
std::equal (a->begin (), a->end (), b->begin ());
1726+
}
1727+
};
1728+
#endif
17151729
#ifdef USE_HASH
17161730
typedef std::unordered_map <const sv_t*, uint, hash_sv, eq_sv> fv2s_t;
17171731
#else
17181732
typedef std::tr1::unordered_map <const sv_t*, uint, hash_sv, eq_sv> fv2s_t;
17191733
#endif
17201734
#else
1735+
#if 0
17211736
struct less_sv : std::binary_function <const sv_t*, const sv_t*, bool> {
17221737
result_type operator () (first_argument_type a, second_argument_type b) const {
17231738
for (const uint* p (a->begin ()), *q (b->begin ());; ++p, ++q) {
@@ -1728,6 +1743,18 @@ namespace opal {
17281743
}
17291744
}
17301745
};
1746+
#else
1747+
struct less_sv {
1748+
bool operator () (const sv_t* a, const sv_t* b) const {
1749+
for (const uint* p (a->begin ()), *q (b->begin ());; ++p, ++q) {
1750+
if (p == a->end ()) return q != b->end ();
1751+
if (q == b->end ()) return false;
1752+
else if (*p < *q) return true;
1753+
else if (*p > *q) return false;
1754+
}
1755+
}
1756+
};
1757+
#endif
17311758
typedef std::map <const sv_t*, uint, less_sv> fv2s_t;
17321759
#endif
17331760
// variables
@@ -2195,7 +2222,7 @@ namespace opal {
21952222
if (rss > _opt.trieT) {
21962223
std::fprintf (stderr,
21972224
"shrink splitN: 2^%lu-1 (= %u) => 2^%u-1 (= %u)\n",
2198-
_nbin, _opt.splitN, i, (1 << i) - 1);
2225+
static_cast<unsigned long>(_nbin), _opt.splitN, i, (1 << i) - 1);
21992226
while (_nbin > i) {
22002227
--_nbin;
22012228
delete _ftrie[_nbin];

0 commit comments

Comments
 (0)