vendredi 22 décembre 2017

clang, std::function and -fno-rtti

I am using clang 5 (on Windows via clang-cl) and have run into a problem trying to turn off runtime type information (-fno-rtti) when using std::function.

Here's my example that won't compile:

#include <iostream>
#include <functional>

void foo(std::function<void()> ra2)
{
}

int main()
{
    std::cout << "Done...";

    std::getchar();

    auto bar = []()
    {
    };

    foo(bar);

    return EXIT_SUCCESS;
}

The error is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\ functional(427,11): error: cannot use typeid with -fno-rtti return (typeid(_Callable));

This surprises me, is there a way to use std::function in clang without rtti? The docs say that only target and target_type on std::function should need rtti. I can roll my own version of std::function, but it seems a shame to have to do so.

Aucun commentaire:

Enregistrer un commentaire