[Prev][Next][Index][Thread]

RE: Knit for C++



> congratulations for getting Knit out of the door.  Nice work!

Thank you - it feels pretty good getting that done.

> I have a heretic question: Does Knit work with C++ modules, and if
> not, what would have to be done to make it so?

A lot depends on what you mean by "works".

C++ is a big language with lots of features like classes, inheritance,
exceptions, constructors, etc. which you _might_ want to take special account
of in a component system.  I think it would be a lot of work to handle all of
C++'s features well.

On the other hand, Knit's primary mode of operation is to just rename symbols
in .o files.  It would probably be fairly straightforward to add g++ name
mangling rules to Knit and it seems like it would be easy to adapt Knit's
initialization ordering code too (though the initialization dependencies would
be more complex in the presence of virtual functions).

(Knit's secondary mode of operation acts directly on the preprocessed C code to
implement cross-module inlining.  In principle it would be easy to adapt this
to C++ code but the sheer size of the C++ grammar makes this a very large,
error-prone task.  Just implementing all the (ill-specified) gcc extensions to
C is a large task.)

--
Alastair Reid

ps If all you need is to rename a few symbols in object files, you could write
a little wrapper program for the rename_dot_o_files program that comes with
Knit.  Obviously, I think Knit is a better option because of all the other
things Knit gives you but if your needs are simple and Knit doesn't do it for
you...


References: