Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions include/roaring/roaring_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifdef __cplusplus
extern "C" {
namespace roaring {
namespace api {
namespace internal {
#endif

/**
Expand All @@ -38,14 +38,20 @@ namespace api {
extern "C++" {
struct container_s {};
}
#define ROARING_CONTAINER_T ::roaring::api::container_s
#define ROARING_CONTAINER_T ::roaring::internal::container_s
#else
#define ROARING_CONTAINER_T void // no compile-time checking
#endif

#define ROARING_FLAG_COW UINT8_C(0x1)
#define ROARING_FLAG_FROZEN UINT8_C(0x2)

#ifdef __cplusplus
} // end namespace internal (but still in namespace roaring)
using internal::container_s; // use scoped to this namespace block
namespace api { // begin API namespace
#endif

/**
* Roaring arrays are array-based key-value pairs having containers as values
* and 16-bit integer keys. A roaring bitmap might be implemented as such.
Expand Down Expand Up @@ -153,7 +159,7 @@ typedef struct roaring_container_iterator_s {
#ifdef __cplusplus
}
}
} // extern "C" { namespace roaring { namespace api {
} // extern "C" { namespace roaring { namespace internal {
#endif

#endif /* ROARING_TYPES_H */
2 changes: 1 addition & 1 deletion src/bitset.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifdef __cplusplus
extern "C" {
namespace roaring {
namespace internal {
namespace api { // bitset_t was once internal, but made public in the API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this comment belongs in the code. That's information for the Git commit message.

#endif

extern inline void bitset_print(const bitset_t *b);
Expand Down
5 changes: 2 additions & 3 deletions src/bitset_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
#ifdef __cplusplus
using namespace ::roaring::internal;
extern "C" {
namespace roaring {
namespace api {
namespace internal {
#endif

#if CROARING_IS_X64
Expand Down Expand Up @@ -1143,7 +1142,7 @@ void bitset_flip_list(uint64_t *words, const uint16_t *list, uint64_t length) {
#ifdef __cplusplus
}
}
} // extern "C" { namespace roaring { namespace api {
} // extern "C" { namespace roaring { namespace internal {
#endif
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
Expand Down
6 changes: 4 additions & 2 deletions src/containers/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ extern inline bool run_container_nonzero_cardinality(const run_container_t *rc);
extern inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs);
extern inline run_container_t *run_container_create_range(uint32_t start,
uint32_t stop);
extern inline int run_container_cardinality(const run_container_t *run);

// not `extern inline` (defined below in this file)
int run_container_cardinality(const run_container_t *run);

bool run_container_add(run_container_t *run, uint16_t pos) {
int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
Expand Down Expand Up @@ -1160,4 +1162,4 @@ int run_container_to_uint32_array(void *vout, const run_container_t *cont,
#endif
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif
1 change: 1 addition & 0 deletions tests/add_offset.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "test.h"
Expand Down
7 changes: 6 additions & 1 deletion tests/c_example1.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

#include "test.h"

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::api;

@AE1020 AE1020 Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon review I notice this line is actually superfluous: including roaring.h (as opposed to roaring.hh) when building as __cplusplus) automatically includes the roaring::api namespace.

https://github.com/RoaringBitmap/CRoaring/blob/master/include/roaring/roaring.h#L1367-L1382

Perhaps that points to a potential separation of configreport.h vs. configreport.hh that does a similar trick; you don't need a using namespace roaring::misc; if you use the .h version?

using namespace roaring::misc;
#endif

bool roaring_iterator_sumall(uint32_t value, void *param) {
*(uint32_t *)param += value;
return true; // iterate till the end
Expand Down Expand Up @@ -162,4 +167,4 @@ int main() {
roaring_bitmap_free(r3);
printf("Success.\n");
return EXIT_SUCCESS;
}
}
4 changes: 4 additions & 0 deletions tests/cbitset_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#include "test.h"

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::api;
#endif

int compute_cardinality(bitset_t *b) {
size_t k = 0;
for (size_t i = 0; bitset_next_set_bit(b, &i); i++) {
Expand Down
1 change: 1 addition & 0 deletions tests/container_comparison_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "test.h"
Expand Down
1 change: 1 addition & 0 deletions tests/cpp_example1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "roaring/roaring64map.hh"

using namespace roaring;

int main() {
Roaring r1;
for (uint32_t i = 100; i < 1000; i++) {
Expand Down
2 changes: 0 additions & 2 deletions tests/cpp_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,6 @@ DEFINE_TEST(test_cpp_contains_range_closed_64) {
// bucket partial.
auto b0 = uint64_t(0);
auto b2 = uint64_t(2) << 32;
auto uint32_max = (std::numeric_limits<uint32_t>::max)();
Roaring64Map r;
r.addRangeClosed(b0, b0 + uint32_max);
r.addRangeClosed(b2, b2 + 5);
Expand All @@ -1077,7 +1076,6 @@ DEFINE_TEST(test_cpp_contains_range_closed_64) {
// bucket.
auto b0 = uint64_t(0);
auto b1 = uint64_t(1) << 32;
auto uint32_max = (std::numeric_limits<uint32_t>::max)();
Roaring64Map r;
r.addRangeClosed(b0, b0 + uint32_max);
assert_false(r.containsRangeClosed(b0, b1));
Expand Down
5 changes: 5 additions & 0 deletions tests/format_portability_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#include <roaring/misc/configreport.h>
#include <roaring/roaring.h>

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "config.h"
#include "test.h"

Expand Down
1 change: 1 addition & 0 deletions tests/mixed_container_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "test.h"
Expand Down
1 change: 1 addition & 0 deletions tests/realdata_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "../benchmarks/numbersfromtextfiles.h"
Expand Down
5 changes: 5 additions & 0 deletions tests/robust_deserialization_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#include <roaring/misc/configreport.h>
#include <roaring/roaring.h>

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "config.h"
#include "test.h"

Expand Down
1 change: 1 addition & 0 deletions tests/run_container_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "test.h"
Expand Down
2 changes: 2 additions & 0 deletions tests/threads_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <roaring/misc/configreport.h>
#include <roaring/roaring.h>

using namespace roaring::internal;

// We are mostly running this test to check for data races using thread
// sanitizer.
void run(roaring_bitmap_t **rarray) {
Expand Down
1 change: 1 addition & 0 deletions tests/toplevel_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "test.h"
Expand Down
1 change: 1 addition & 0 deletions tests/util_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#ifdef __cplusplus // stronger type checking errors if C built in C++ mode
using namespace roaring::internal;
using namespace roaring::misc;
#endif

#include "test.h"
Expand Down
Loading