can't use C++ 2011 lambda functions in host functions?

Has anybody been able to use NVCC to compile lambda functions inside host functions? I tried this but it fails with “/opt/gcc4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include/stddef.h(432): error: identifier “nullptr” is undefined”

int main()
  auto myfunc = [&]()
  return 0;

<i>nvcc --compiler-bindir /opt/gcc4.8/bin -Xcompiler -std=c++11</i>

It seems NVCC is trying to compile C++ 2011 host code and failing. But why would it do that? I thought it was only supposed to compile the device functions and the <<< >>> kernel launch notations, and leave the rest to the host compiler?

Well it still needs to parse the host code even if it isn’t compiling in order to see where functions end.
No idea how clever the parser is (whether it just matches curly braces or does an actual syntax check) - never seemed worth experimenting with that.

OK, I see. I agree NVCC needs to parse the code, but what it’s doing here is checking that all variables have been declared and that the types match. This step is separate from parsing (usually done right after)

I guess maybe NVCC does need to do type checking, so that you don’t do MyKernel<<<apples, rocks, oranges>>>();

Guess, I’ll have to move my lambda function out of the .cu

Moving code using C++11 features out of .cu files and into separate .cpp files is what I would recommend for now.