1

Is there a way to have the C++ Prepossessor print the code for all auto generated functions such as copy and move constructors, along with copy and move assignment operators via a command line option to perhaps g++ or clang?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
David Ryan
  • 81
  • 1
  • 6
  • 1
    Possible duplicate of [view the default functions generated by a compiler?](http://stackoverflow.com/questions/2129200/view-the-default-functions-generated-by-a-compiler) – kfsone Aug 05 '16 at 19:36

2 Answers2

6

No, prepossessor is working on your source code, treating it as just a text, before c++ compilation starts and it does not perform C++ syntax analysis, it is unaware of any c++ language constructs. The output of preprocessor, which is another text, is used as input for actual c++ compilation

Having said that, I want also to mention very interesting article that I read just today - Can Qt's moc be replaced by C++ reflection, which along other things also touches a bit question about reflection in C++ language and links to Call for Compile-Time Reflection Proposals. So it looks like we just need to wait a bit and what you are asking for will become possible soon :)

mvidelgauz
  • 2,176
  • 1
  • 16
  • 23
0

There is not. Not as C++ code at least. If you count dumping the generated asm, look at the -S switch.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70