Skip to content

Commit

Permalink
add get_version() for c_api. (facebookresearch#3688)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebookresearch#3688

Test PR.

Differential Revision: D60207739
  • Loading branch information
bshethmeta authored and facebook-github-bot committed Jul 25, 2024
1 parent aed7b0e commit 67bfbee
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions c_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(FAISS_C_SRC
index_io_c.cpp
impl/AuxIndexStructures_c.cpp
utils/distances_c.cpp
utils/utils_c.cpp
)
add_library(faiss_c ${FAISS_C_SRC})
target_link_libraries(faiss_c PRIVATE faiss)
Expand Down
16 changes: 16 additions & 0 deletions c_api/utils/utils_c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// Copyright 2004-present Facebook. All Rights Reserved.
// -*- c++ -*-

#include "utils_c.h"
#include <faiss/utils/index.h>

const char* get_version() {
return VERSION_STRING;
}
27 changes: 27 additions & 0 deletions c_api/utils/utils_c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// Copyright 2004-present Facebook. All Rights Reserved.
// -*- c -*-

#ifndef FAISS_UTILS_C_H
#define FAISS_UTILS_C_H

#include <stdint.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

const char* get_version();

#ifdef __cplusplus
}
#endif

#endif
2 changes: 1 addition & 1 deletion faiss/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ std::string get_compile_options() {
return options;
}

std::string get_version() {
const char* get_version() {
return VERSION_STRING;
}

Expand Down
2 changes: 1 addition & 1 deletion faiss/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ std::string get_compile_options();
**************************************************/

// Expose FAISS version as a string
std::string get_version();
const char* get_version();

/// ms elapsed since some arbitrary epoch
double getmillisecs();
Expand Down

0 comments on commit 67bfbee

Please sign in to comment.