473,395 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Automatic C++ header generation?

I have begun designing and programming in C++ after a several years
away from software engineering/programming.

I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed

The only tools I have found are "chic" and "lzz".

Chic apparently wants to talk to an Xserver, thus leading me to
believe it runs as a gui and is therefore does not appear to have a
cmdline-only option. (...and I'm unable to run it on a remote machine
easily)

lzz appears to 1) want to change the input .cpp file, and 2) can not
parse my more-complex .cpp file.

All of this seems quite disappointing. I was hoping this task would
not be hard to automate.

All of my source "g++ -ansi" compiles nicely.

Any toughts/suggestions?

-Matt

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #1
6 10215
Matt wrote:
I have begun designing and programming in C++ after a several years
away from software engineering/programming.

I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed

The only tools I have found are "chic" and "lzz".

Chic apparently wants to talk to an Xserver, thus leading me to
believe it runs as a gui and is therefore does not appear to have a
cmdline-only option. (...and I'm unable to run it on a remote machine
easily)

lzz appears to 1) want to change the input .cpp file, and 2) can not
parse my more-complex .cpp file.

All of this seems quite disappointing. I was hoping this task would
not be hard to automate.

All of my source "g++ -ansi" compiles nicely.

Any toughts/suggestions?

-Matt

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


I been working on my own header generator tool, a GUI for
Windows platform. I was working on a database for inheritance
and include files. For example, you could select from various
design patterns: Singleton, equality, comparable, binary I/O,
and it would create the stencils for those methods in the class.

When specifying members, it would look up the types in the
database and provide the necessary include headers.

I've learned a lot more about C++, and coding styles since I
started the project. When I get the time, I need to go back
and redesign (refactor?) it. ;-)

In summary, this should not be a big task to write one yourself.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #2
Matt wrote:
I have begun designing and programming in C++ after a several years
away from software engineering/programming.

I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed


Most things should be in .cpp files.

..h file should be very light.

If a brute-force script read a .cpp file and wrote a .h file, it wouldn't
know what to exclude. Large C++ programs can compile very slowly when their
..h files include more .h files, all containing much more stuff than each
translation unit actually needs.

Small C++ programs have no need of a .h file generator, because they should
have only a very few things to put in a .h file.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #3
Matt wrote:
I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed


I think you're doing it in the wrong direction. The interface has to be
determined and written first, and then the implementation should follow.

So, what you probably need is a program that reads the interface from
the given header file and generates the stub for the implementation.
For example:

////////////////////////////////////////////////////////
// input: C.h
////////////////////////////////////////////////////////

class C
{
public:
void foo(char a, int b) const;

private:
static const double data[];
};

////////////////////////////////////////////////////////
// output: C.c++
////////////////////////////////////////////////////////

#include "C.h"

const double C::data[] = { };

void C::foo(char a, int b) const
{
}

--
Seungbeom Kim

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #4

Hi,

Matt <ma**@downwithspammers-mengland.net> writes:
1) command-line oriented tool
Tick mark for lzz.
2) input .cpp files, output .h files
3) do not change the .cpp files if directed
I think that point 2 and 3 cannot be both satisfied in C++. The
problem constructs being templates and inlining.

In order for the inline and template bodies to be available, they
should either go into the header file or a seperate file to be
included by other translation units.

In order for the generator to see these definitions, it will need to
be in the 'source' to the tool, and if this 'source' is also going to
be seen by your compiler, then the tool would have to modify the
source so that the compiler doesn't get a duplicate definition.
lzz appears to 1) want to change the input .cpp file,
lzz was designed to be driven by a seperate '.lzz' file. However, the
syntax in this file was kept as *standard* C++. lzz then
intelligently places declarations and definitions into the resulting
'.h' and '.cpp' files. Where you desire seperate files for template
bodies or inline functions, it can also be configured to create those
files too.
and 2) can not parse my more-complex .cpp file.
I would be very interested to see exactly what you are trying to
parse. The author of lzz is responsible for the grammar
implementation in the front end of our C++ parser. We also use 'lzz'
in house, and we are not shy about using C++ features.

For someone just looking at lzz, I can imagine that there are some
simple things that might not be obvious. For example, so that lzz
doesn't need to worry about C++ declaration ambiguities you must
always declare function parameter names.

void foo (int const &) {} // not accepted
void foo (int const &i) {} // ok

This allows lzz to parse C++ without needing a heavy semantic backend.
All of this seems quite disappointing. I was hoping this task would
not be hard to automate.


We now have about 350k of lines of lzz code, and I now find it alien
to have to write both a header and source file. As you may have
noticed, I am not shy about promoting the use of lzz, I think it
should be part of everybodies tool kit.
If you have a set of examples that you feel should be handled, I know
that the author will be very responsive, even if it is just to modify
the help.

Since it would be OT here, if you mail me directly some of the
examples I too maybe able to help.
Regards,

Richard
--
Richard Corden
To reply remove 's' from address

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #5
"Matt" <ma**@downwithspammers-mengland.net> wrote in message
news:3s********************************@4ax.com...
I have begun designing and programming in C++ after a several years
away from software engineering/programming.

I am looking for an "automatic C++ header generator." I have what
seems to be fairly simple requirements:

1) command-line oriented tool
2) input .cpp files, output .h files
3) do not change the .cpp files if directed


Google for "Lazy C++".

Andrei

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #6
Hello Richard, et al,

Thanks so much for all the feedback to this point.

One of the problems I had to conquer was my misunderstanding of C++
header-file and body-file relationships. Once I got over that, things
became easier to understand.

In the end, however, I see that it might be difficult for me to
completely automate the generation of head files; there seems too much
benefit from human formatting and commenting. However, the automation
can help save a lot of mundane work.

The lzz problem with a specific part of source code remains; however,
it's not at this point a stumbling block, but if it is in the future,
I may email the lzz author(s) with the question/info.

Thanks again!
-Matt
On 21 Nov 2004 18:29:24 -0500, Richard Corden
<ri*************@hotmail.com> wrote:
We now have about 350k of lines of lzz code, and I now find it alien
to have to write both a header and source file. As you may have
noticed, I am not shy about promoting the use of lzz, I think it
should be part of everybodies tool kit.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rasmus Fogh | last post by:
Someone raised the question of automatic code generation a few weeks back. And yes, we (CCPN) are using automatic Python code generation in a major way. Basically we are making data models in...
15
by: Kannan Goundan | last post by:
Maintaining a C++ header file can be painful. I want a way to automatically generate header files from the implementation file. Does anybody know of a program that does this? If not, I'd like...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
4
by: Petterson Mikael | last post by:
Hi, Anyone out there that knows of a automatic test generation tool for cpp? Another requirement is that the test results should be presented in xml. All hints appreciated. cheers, ...
1
by: woessner | last post by:
I have a lot of classes which derive from a common base class. I want to be able to clone objects of these types so I have given the base class a pure virtual clone method. The derived classes...
0
by: JoshforRefugee | last post by:
heard that we can do automatic code generation using macros, but not sure how can I pursue this. Here is my problem. In my env, I have class A,B and C. All of them has constructors, and few...
9
by: puzzlecracker | last post by:
From my understanding, if you declare any sort of constructors, (excluding copy ctor), the default will not be included by default. Is this correct? class Foo{ public: Foo(int); // no...
25
by: sidd | last post by:
In the following code: int i = 5; ---it goes to .data segment int j; ---it goes to bss segment int main() { int c; int i = 5; ---stack
34
by: =?ISO-8859-1?Q?Marcel_M=FCller?= | last post by:
Hi, is there a way to avoid the automatic copy constructor generation. I do not want the object to be non-copyable. I simply do not want that copying is done by the default copy constructor. But...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.