Skip to content

Commit 67bfbee

Browse files
bshethmetafacebook-github-bot
authored andcommitted
add get_version() for c_api. (#3688)
Summary: Pull Request resolved: #3688 Test PR. Differential Revision: D60207739
1 parent aed7b0e commit 67bfbee

File tree

5 files changed

+46
-2
lines changed

5 files changed

+46
-2
lines changed

c_api/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set(FAISS_C_SRC
3030
index_io_c.cpp
3131
impl/AuxIndexStructures_c.cpp
3232
utils/distances_c.cpp
33+
utils/utils_c.cpp
3334
)
3435
add_library(faiss_c ${FAISS_C_SRC})
3536
target_link_libraries(faiss_c PRIVATE faiss)

c_api/utils/utils_c.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// Copyright 2004-present Facebook. All Rights Reserved.
9+
// -*- c++ -*-
10+
11+
#include "utils_c.h"
12+
#include <faiss/utils/index.h>
13+
14+
const char* get_version() {
15+
return VERSION_STRING;
16+
}

c_api/utils/utils_c.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// Copyright 2004-present Facebook. All Rights Reserved.
9+
// -*- c -*-
10+
11+
#ifndef FAISS_UTILS_C_H
12+
#define FAISS_UTILS_C_H
13+
14+
#include <stdint.h>
15+
#include <stdlib.h>
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
const char* get_version();
22+
23+
#ifdef __cplusplus
24+
}
25+
#endif
26+
27+
#endif

faiss/utils/utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ std::string get_compile_options() {
130130
return options;
131131
}
132132

133-
std::string get_version() {
133+
const char* get_version() {
134134
return VERSION_STRING;
135135
}
136136

faiss/utils/utils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::string get_compile_options();
3838
**************************************************/
3939

4040
// Expose FAISS version as a string
41-
std::string get_version();
41+
const char* get_version();
4242

4343
/// ms elapsed since some arbitrary epoch
4444
double getmillisecs();

0 commit comments

Comments
 (0)