Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Xcode 7.2 does not support thread_local => no way to build the MySQL connector for sqlpp11 #5

Closed
juandent opened this issue Feb 5, 2016 · 9 comments

Comments

@juandent
Copy link

juandent commented Feb 5, 2016

Hi,

After much searching around, I have been stopped by the frustrating reality that Xcode 7.2 does not yet support thread_local variables and thus it is currently impossible to build "sqlpp11-connector-mysql-master". Connection.cpp uses this like so:

void execute_statement(detail::connection_handle_t& handle, const std::string& statement)
{
thread_local MySqlThreadInitializer threadInitializer;

    if (handle.config->debug)
      std::cerr << "MySQL debug: Executing: '" << statement << "'" << std::endl;

    if (mysql_query(handle.mysql.get(), statement.c_str()))
    {
      throw sqlpp::exception("MySQL error: Could not execute MySQL-statement: " +
                             std::string(mysql_error(handle.mysql.get())) + " (statement was >>" + statement +
                             "<<\n");
    }
  }

If someone knows a workaround, I would be deeply grateful! Such a shame for a great library...'

Thanks again,
Juan

@rbock
Copy link
Owner

rbock commented Feb 6, 2016

Hi Juan,

I currently can't test with Xcode directly, but I will setup testing on travis.ci soon.

For the time being, please try to use boost.thread:

static boost::thread_specific_ptr<MySqlThreadInitializer> mysqlThreadInit;
if (!mysqlThreadInit.get()
{
     mysqlThreadInit.reset(new MysqlThreadInit);
}

Best,

Roland

@juandent
Copy link
Author

juandent commented Feb 7, 2016

Hi Roland!

Your idea worked!! Thank you so much!!

Juan

@rbock
Copy link
Owner

rbock commented Feb 7, 2016

Glad it worked out :-)

@rbock rbock closed this as completed Feb 7, 2016
@CapSel
Copy link

CapSel commented Oct 21, 2017

This solution is really bad.
C++ from Apple does not support thread_local but the "original" clang/libc++ support it. This is very old BUG or FEATURE of Apple's XCode environment - not clang/llvm/libc++.

@rbock
Copy link
Owner

rbock commented Oct 21, 2017

So what would be a good solution?

@CapSel
Copy link

CapSel commented Oct 21, 2017

The "best" solution is for Apple to fix this issue.
Simplest solution is to test for __APPLE__.

@CapSel
Copy link

CapSel commented Oct 21, 2017

@rbock
Copy link
Owner

rbock commented Oct 21, 2017

Since I don't think I have that kind of pull at Apple, I like the __APPLE__ version best.

Care to write a pull request?

@CapSel
Copy link

CapSel commented Oct 21, 2017

#29
How can I fix issue from AppVeyor?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants