|Automatic header generation for C++ firstname.lastname@example.org (2002-03-11)|
|Re: Automatic header generation for C++ email@example.com (Michael Spencer) (2002-03-17)|
|From:||Michael Spencer <firstname.lastname@example.org>|
|Date:||17 Mar 2002 22:10:09 -0500|
|Posted-Date:||17 Mar 2002 22:10:09 EST|
> I'm interested in obtaining a tool that takes a C++ source file
> (.cc-files) and generates the corresponding header file (.h-file)
> - all #include directives from the .cc-file.
> - all function prototypes from the .cc-file.
> - the prototype of each function defined in the .cc-file.
> - all extern declarations from the .cc-file.
> - an extern declaration for each data item defined in the .cc-file.
> - all typedef's from the .cc-file
> - all declarations of struct or class types in the .cc-file
> - whatever else the .h-file ought to have.
> In addition it would have to have code to adjust the line numbers to
> correspond to those of widget.cc, so that if there were an error in
> compiling the .h-file, the programmer could edit the corresponding
> line of the .cc-file.
lzz (http://www.lazycplusplus.com) does something very similar. In
lzz you write your component in one file. Lzz reads this file and
puts things where they belong (according to generally accepted
It does not however recognize #include directives (or other
preprocessing directives) outside of function bodies. You must
explicitly indicate where the directives go:
#define BAR FOO
Do you really want all your #include directives to go in the header
If you choose, Lzz will output inline definitions to a .inl-file,
template definitions to a .tpl-file, and inline template definitions
to a .tnl-file. You'd use a .tpl-file if you prefer to explicitly
instantiate your templates. (All the extensions can be changed.)
The biggest drawback for some people is the lack of macro support.
Lzz does not recognize macros (except in one special case) outside of
expressions and function bodies, unless the code is still recognizable
as C++. I find this to be an advantage: I do not need to dig through
header files to understand the syntax of the code I'm looking at (I
know I'm part of the minority here :).
Lzz can save you lots of time: you will never forget to edit a header
file after modifying a source file. I just can't happen. You'll also
write safer code. For example, using directives are output to the
source file. And the header file has to be self contained or the
source file won't compile.
Lzz uses a (minimum state, context-aware) backtracking LR(1) parser
generator. It is available at http://www.lazycplusplus.com/basil.
Return to the
Search the comp.compilers archives again.