Skip to content

Commit 93a01ff

Browse files
committed
Avoid ODR violations from copy-pasted struct definition.
Interesting that this wasn't picked up in the ~5 years that it was introduced, but I guess that newer compilers are less cavalier about it.
1 parent a1b8da1 commit 93a01ff

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: DropletUtils
2-
Version: 1.29.3
3-
Date: 2025-06-13
2+
Version: 1.29.4
3+
Date: 2025-07-02
44
Title: Utilities for Handling Single-Cell Droplet Data
55
Authors@R: c(
66
person("Aaron", "Lun", role = "aut"),

src/find_chimeric.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@
44
#include <vector>
55
#include <algorithm>
66

7-
struct molecule {
8-
molecule (size_t i, int u) : index(i), umi(u) {}
9-
10-
// need to handle situations where one sample has >2e9 UMIs.
11-
// otherwise, using ints for memory efficiency.
12-
size_t index;
13-
int umi;
14-
};
15-
167
//[[Rcpp::export(rng=false)]]
178
Rcpp::List find_chimeric(Rcpp::StringVector cells, Rcpp::IntegerVector umis,
189
Rcpp::IntegerVector reads, double minfrac, bool diagnostics)
@@ -22,6 +13,15 @@ Rcpp::List find_chimeric(Rcpp::StringVector cells, Rcpp::IntegerVector umis,
2213
throw std::runtime_error("'reads', 'umis', 'cells' should be of the same length");
2314
}
2415

16+
struct molecule {
17+
molecule (size_t i, int u) : index(i), umi(u) {}
18+
19+
// need to handle situations where one sample has >2e9 UMIs.
20+
// otherwise, using ints for memory efficiency.
21+
size_t index;
22+
int umi;
23+
};
24+
2525
std::vector<molecule> ordering;
2626
ordering.reserve(nmolecules);
2727
auto uIt=umis.begin();

src/find_swapped.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ void compare_lists(U left, V right) {
3131
return;
3232
}
3333

34-
struct molecule {
35-
molecule (int s, size_t i, int g, int u) : index(i), sample(s), gene(g), umi(u) {}
36-
37-
// need to handle situations where one sample has >2e9 UMIs.
38-
// otherwise, using ints for memory efficiency.
39-
size_t index;
40-
int sample, gene, umi;
41-
};
42-
4334
/* Identifies which molecules should be retained in which samples,
4435
* given the cell, gene and UMI combination for each molecule per sample.
4536
* Also returns a diagnostic matrix of molecule-sample read counts.
@@ -56,6 +47,15 @@ Rcpp::List find_swapped(Rcpp::List cells, Rcpp::List genes, Rcpp::List umis, Rcp
5647
compare_lists(Cells, Umis);
5748
compare_lists(Cells, Reads);
5849

50+
struct molecule {
51+
molecule (int s, size_t i, int g, int u) : index(i), sample(s), gene(g), umi(u) {}
52+
53+
// need to handle situations where one sample has >2e9 UMIs.
54+
// otherwise, using ints for memory efficiency.
55+
size_t index;
56+
int sample, gene, umi;
57+
};
58+
5959
// Setting up the ordering vector.
6060
const size_t nsamples=Cells.size();
6161
size_t nmolecules=0;

0 commit comments

Comments
 (0)