Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to automate C++ header/source separation

I find it extremely tiring that I have to update code in two places whenever I'm developing a C++ class. During development, it happens 100+ times (at least for each private method) that I change the declaration of a method, add a const here or there, remove a & reference and so on. I literally hate it that I have to open a second file (the header file) every time I do a little change, and I've seen myself trying to avoid doing private interface changes in the middle of development just because I want to avoid this pain. (You probably think I'm lazy. I am, but it's also a REAL pain that stops me from being as productive as I could be.)

Usually, all of my declarations are in the header, and all of the definitions are in the source. I don't care about inlining or clever little optimization tricks. I love many things about C++, but I'd love it even more if refactoring and developing interfaces was as straightforward as in Java.

Are there any hints for dealing with the situation?

like image 874
Hinton Avatar asked Jan 24 '14 12:01

Hinton


1 Answers

You could look at LZZ which generates header and source files from single .lzz file. Downside of using it that it not always plays nicely with IDE. For example in my case with Visual Studio + Visual Assist - you could setup syntax highlighting, debug is also working properly and walks in lzz source (but you couldn't walk or set breakpoint in generated .h/.cpp files), but when you looking for declaration you often find it in .h file instead of .lzz. I personally prefer to live without lzz and use IDE for refactoring and quick jumps between declarations and definitions, but some people do not want to wait for c++14 modules and use lzz.

like image 186
ISanych Avatar answered Oct 19 '22 23:10

ISanych