-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gcc 6.1.1 compiling problem about 'does not match any template declaration' #55
Comments
@semsevens Thanks for reporting this, i will install gcc-6.1 and try to reproduce this. |
@semsevens Thanks for the article, i think I've merged with your fork first ( i hope you don't mind :-) ) and then made sure all our tests pass with I hope MSVC doesn't complain about this, which shouldn't. |
@aminroosta , 366 get_col_from_db(db, sizeof...(Values), value); I will get following errors: /usr/local/include/sqlite_modern_cpp.h:366: undefined reference to `void sqlite::get_col_from_db<bool>(sqlite::database_binder&, int, bool&)'
/tmp/ccqEtE2a.o: In function `std::enable_if<(sizeof (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool, bool, bool))<(10ul), void>::type sqlite::binder<10ul>::run<Data::SetCalendars()::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool, bool, bool, bool, bool, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#1}, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool, bool, bool, 10ul>(sqlite::database_binder&, Data::SetCalendars()::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool, bool, bool, bool, bool, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)#1}&, (std::enable_if&&)...)':
/usr/local/include/sqlite_modern_cpp.h:366: undefined reference to `void sqlite::get_col_from_db<bool>(sqlite::database_binder&, int, bool&)'
/tmp/ccqEtE2a.o:/usr/local/include/sqlite_modern_cpp.h:366: more undefined references to `void sqlite::get_col_from_db<bool>(sqlite::database_binder&, int, bool&)' follow After I delete this line, no error occurs when compiling. |
@semsevens That line gets values returned from database to pass to the lambda function call. Can you please write a minimal program that fails to compile with the last version of library. |
@aminroosta Here is the minimal program: #include<iostream>
#include <sqlite_modern_cpp.h>
using namespace sqlite;
using namespace std;
int main() {
try {
// creates a database file 'dbfile.db' if it does not exists.
database db("dbfile.db");
// executes the query and creates a 'user' table
db <<
"create table if not exists user ("
" _id integer primary key autoincrement not null,"
" age int,"
" name text,"
" weight real,"
" handsome int"
");";
db << "insert into user (age,name,weight,handsome) values (?,?,?,?);"
<< 20
<< u"bob"
<< 83.25
<< true;
db << "select age,name,weight,handsome from user where age > ? ;"
<< 18
>> [&](int age, string name, double weight, bool handsome) {
cout << age << ' ' << name << ' ' << weight << ' ' << handsome << endl;
};
}
catch (exception& e) {
cout << e.what() << endl;
}
} I think I figure out why following errors occurred: /usr/local/include/sqlite_modern_cpp.h:366: undefined reference to `void sqlite::get_col_from_db<bool>(sqlite::database_binder&, int, bool&)' It's the
So does the
|
Supporting booleans by converting them to and back from integers makes the library more consistent. @semsevens Are you interested to send a PR for this? 😉 |
Yeah, I send a PR. |
The library works well when I use Fedora 23 whose gcc's version is gcc-c++-5.3.1-6.fc23.x86_64.rpm.
But after I updated to Fedora 24 in which gcc's version is gcc-c++-6.1.1-3.fc24.x86_64.rpm, the problem occurred.
When I compiling my project, It shows:
I'm very confused.
After I reading this article -- Why Not Specialize Function Templates?, I think it may due to the specialized function templates.
So I replace all specialized function templates with nontemplate functions and add them to be friends of class database_binder in file
/usr/local/include/sqlite_modern_cpp.h
.And then it works.
Although this solved my problem, but I think it may be not the best way.
Here is my solution: Comparing changes
The text was updated successfully, but these errors were encountered: