fork(1) download
  1. #include <iostream>
  2. #define MACRO(y, x) void _func_##x() { \
  3. some.##y.func_##x(); \
  4. }
  5.  
  6. class first
  7. {
  8. public:
  9. void func_example(const char* str)
  10. {
  11. std::cout << str;
  12. }
  13. };
  14.  
  15. class second
  16. {
  17. public:
  18. first othersome;
  19. } some;
  20.  
  21. MACRO(othersome, example);
  22.  
  23. int main()
  24. {
  25. _func_example("Hello, World!");
  26.  
  27. return 0;
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:6: error: pasting "." and "othersome" does not give a valid preprocessing token
  some.##y.func_##x(); \
      ^
prog.cpp:21:1: note: in expansion of macro ‘MACRO’
 MACRO(othersome, example);
 ^
prog.cpp: In function ‘void _func_example()’:
prog.cpp:3:20: error: no matching function for call to ‘first::func_example()’
  some.##y.func_##x(); \
                    ^
prog.cpp:21:1: note: in expansion of macro ‘MACRO’
 MACRO(othersome, example);
 ^
prog.cpp:3:20: note: candidate is:
  some.##y.func_##x(); \
                    ^
prog.cpp:21:1: note: in expansion of macro ‘MACRO’
 MACRO(othersome, example);
 ^
prog.cpp:9:7: note: void first::func_example(const char*)
  void func_example(const char* str)
       ^
prog.cpp:9:7: note:   candidate expects 1 argument, 0 provided
prog.cpp: In function ‘int main()’:
prog.cpp:25:31: error: too many arguments to function ‘void _func_example()’
  _func_example("Hello, World!");
                               ^
prog.cpp:2:26: note: declared here
 #define MACRO(y, x) void _func_##x() { \
                          ^
prog.cpp:21:1: note: in expansion of macro ‘MACRO’
 MACRO(othersome, example);
 ^
stdout
Standard output is empty