Skip to content

Commit 179ef09

Browse files
committed
define preprocesor definition
define NON_AMBIGOUS_OVERLOAD to prevent ambiguous overload and use int instead of long to prevent ambiguous overload errors
1 parent 6b6078a commit 179ef09

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

meson.build

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ sqlitecpp_deps = [
4646
sqlite3_dep,
4747
thread_dep,
4848
]
49+
## used to override the default sqlitecpp options like cpp standard
50+
sqlitecpp_opts = []
4951

5052
## tests
5153

@@ -59,6 +61,10 @@ sqlitecpp_test_srcs = [
5961
'tests/Exception_test.cpp',
6062
'tests/ExecuteMany_test.cpp',
6163
]
64+
sqlitecpp_test_args = [
65+
# do not use ambiguous overloads by default
66+
'-DNON_AMBIGOUS_OVERLOAD'
67+
]
6268

6369
## samples
6470

@@ -131,10 +137,11 @@ libsqlitecpp = library(
131137
include_directories: sqlitecpp_incl,
132138
cpp_args: sqlitecpp_args,
133139
dependencies: sqlitecpp_deps,
140+
# override the default options
141+
override_options: sqlitecpp_opts,
134142
# install: true,
135143
# API version for SQLiteCpp shared library.
136-
version: '0',
137-
)
144+
version: '0',)
138145

139146
install_headers(
140147
'include/SQLiteCpp/SQLiteCpp.h',
@@ -164,10 +171,12 @@ if get_option('SQLITECPP_BUILD_TESTS')
164171
sqlitecpp_dep,
165172
sqlite3_dep,
166173
]
167-
sqlitecpp_test_args = []
168174

169175
testexe = executable('testexe', sqlitecpp_test_srcs,
170-
dependencies: sqlitecpp_test_dependencies)
176+
dependencies: sqlitecpp_test_dependencies,
177+
cpp_args: sqlitecpp_test_args,
178+
# override the default options
179+
override_options: sqlitecpp_opts,)
171180

172181
test_args = []
173182

@@ -177,7 +186,9 @@ if get_option('SQLITECPP_BUILD_EXAMPLES')
177186
## demo executable
178187
sqlitecpp_demo_exe = executable('SQLITECPP_sample_demo',
179188
sqlitecpp_sample_srcs,
180-
dependencies: sqlitecpp_dep)
189+
dependencies: sqlitecpp_dep,
190+
# override the default options
191+
override_options: sqlitecpp_opts,)
181192
endif
182193

183194
pkgconfig = import('pkgconfig')

tests/Statement_test.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,12 @@ TEST(Statement, bindings)
374374
// Sixth row with uint32_t unsigned value and a long value (which is either a 32b int or a 64b long long)
375375
{
376376
const uint32_t uint32 = 4294967295U;
377+
// preprocessor define to force not use long and use instead uint
378+
#if NON_AMBIGOUS_OVERLOAD
379+
const int integer = -123;
380+
#else
377381
const long integer = -123;
382+
#endif
378383
insert.bind(2, uint32);
379384
insert.bind(3, integer);
380385
EXPECT_EQ(1, insert.exec());
@@ -493,7 +498,11 @@ TEST(Statement, bindByName)
493498
{
494499
const std::string second("second");
495500
const int64_t int64 = 12345678900000LL;
501+
#if NON_AMBIGOUS_OVERLOAD
502+
const int integer = -123;
503+
#else
496504
const long integer = -123;
505+
#endif
497506
const float float32 = 0.234f;
498507
insert.bind("@msg", second);
499508
insert.bind("@int", int64);
@@ -606,7 +615,11 @@ TEST(Statement, bindByNameString)
606615
{
607616
const std::string second("second");
608617
const int64_t int64 = 12345678900000LL;
618+
#if NON_AMBIGOUS_OVERLOAD
619+
const int integer = -123;
620+
#else
609621
const long integer = -123;
622+
#endif
610623
const float float32 = 0.234f;
611624
insert.bind(amsg, second);
612625
insert.bind(aint, int64);

0 commit comments

Comments
 (0)