Skip to content

Commit c4418ea

Browse files
authored
Merge pull request #508 from jlmelville/develop
Provide a macro to override the use of std::cerr
2 parents ae5ba1b + a9e62cb commit c4418ea

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

hnswlib/hnswalg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
105105
if ( M <= 10000 ) {
106106
M_ = M;
107107
} else {
108-
std::cerr << "warning: M parameter exceeds 10000 which may lead to adverse effects." << std::endl;
109-
std::cerr << " Cap to 10000 will be applied for the rest of the processing." << std::endl;
108+
HNSWERR << "warning: M parameter exceeds 10000 which may lead to adverse effects." << std::endl;
109+
HNSWERR << " Cap to 10000 will be applied for the rest of the processing." << std::endl;
110110
M_ = 10000;
111111
}
112112
maxM_ = M_;

hnswlib/hnswlib.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#pragma once
2+
3+
// https://github.com/nmslib/hnswlib/pull/508
4+
// This allows others to provide their own error stream (e.g. RcppHNSW)
5+
#ifndef HNSWLIB_ERR_OVERRIDE
6+
#define HNSWERR std::cerr
7+
#else
8+
#define HNSWERR HNSWLIB_ERR_OVERRIDE
9+
#endif
10+
211
#ifndef NO_MANUAL_VECTORIZATION
312
#if (defined(__SSE__) || _M_IX86_FP > 0 || defined(_M_AMD64) || defined(_M_X64))
413
#define USE_SSE

0 commit comments

Comments
 (0)