Re: Compiling modules: understanding filename conventions

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

 



On 05.05.23 09:36, Jonathan Wakely wrote:
On Fri, 5 May 2023 at 06:09, Wilhelm Meier wrote:

Hi all,

I think, I have some misconceptions about compiling modules :-(

Say, I have a module interface unit modA.hxx and a module implementation
unit modA.cxx for module A. If I compile modA.hxx I get the bmi in
gcm.cache and a file modA.o. I need the bmi to compile the modA.cxx, but
this overrides modA.o. This does not harm, since modA.o from modA.hxx
looks more or less empty. Linking with the (overridden) file modA.o does
work.

A module interface unit is not a header, so there's no reason to use a
.hxx extension. So if you name them something like modA_intf.cxx and
modA_impl.cxx then you avoid the problem.

Ok, make much more sense!
Especially because module interface units may safely contain definitions.

You can also use -fmodule-only to inhibit creation of the .o file (GCC
doesn't know whether you intend to compile a module interface unit or
a module implementation unit, so it treats them the same and assumes
you want a linkable .o file).

So, if all entities in the module interface unit are (implicitly) inline, one can safely use -fmodule-only?

I think, that would be best strategie to convert a header-only library.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux