fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <functional>
  4.  
  5. using namespace std;
  6.  
  7. struct a {
  8. static std::function<int(const int )> my_lambda;
  9.  
  10. } sa;
  11.  
  12. // geht gar nicht
  13. // a::my_lambda = [](const int in) { return 4 * in; } ;
  14.  
  15.  
  16. int main() {
  17.  
  18. // geht so lala
  19. a::my_lambda = [](const int in) { return 4 * in; } ;
  20.  
  21. int lambda_out = a::my_lambda(3);
  22.  
  23. cout << lambda_out << endl;
  24.  
  25. return 0;
  26. }
  27.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /home/v6nX3s/prog-659e02.o: in function `main':
prog.cpp:(.text+0xa): undefined reference to `a::my_lambda'
/usr/bin/ld: prog.cpp:(.text+0x16): undefined reference to `a::my_lambda'
/usr/bin/ld: prog.cpp:(.text+0x3c): undefined reference to `a::my_lambda'
/usr/bin/ld: prog.cpp:(.text+0x5a): undefined reference to `a::my_lambda'
/usr/bin/ld: prog.cpp:(.text+0x78): undefined reference to `a::my_lambda'
/usr/bin/ld: /home/v6nX3s/prog-659e02.o:prog.cpp:(.text+0x7e): more undefined references to `a::my_lambda' follow
clang: error: linker command failed with exit code 1 (use -v to see invocation)
stdout
Standard output is empty