This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Proposal for automatic generation of c++ header files


On 14 January 2011 16:39, Achilleas Margaritis wrote:
>
> I have already explained it, but I don't mind explaining it once more:
>
> 1) the pragma #autoinclude ("foo.hpp", "foo.cpp") instructs the
> compiler to generate the header 'foo.hpp' from the implementation file
> 'foo.cpp'.
>
> 2) the compiler opens the file 'foo.cpp'.
>
> 3) for every class found in the file 'foo.cpp', a relevant class is
> placed into the header.

You've forgotten something.  What about headers included by foo.cpp?

You need to think in terms of translation units, not "foo.cpp" because
it would be possible to mix and match #include and autoinclude, so
foo.cpp might contain declarations and definitions from multiple
files.  They can't all be included directly into the auto-generated
foo.hpp because that would ignore include guards. Consider:

// main.cpp
#include "bar.h"
#pragma autoinclude("foo.hpp", "foo.cpp")

If foo.cpp also includes bar.h then main.cpp would end up with that
file included twice.

So the auto-generated header would need to include bar.h *with* its
include guards (which means including it *before* preprocessing, which
is a big change to the stages of compilation)

or it would need to output #include "bar.h" into foo.hpp, which is
also a big change to the stages of compilation, as autoinclude needs
to happen before preprocessing.

(Should it also happen before converting the input files from the
basic source character set to the execution character set?  Let me
guess, you haven't thought about those details.)


On 14 January 2011 16:18, Achilleas Margaritis wrote:
> On Fri, Jan 14, 2011 at 6:20 PM, Richard Kenner wrote:
>>>
>>> Feel free to correct me if I am mistaken.
>>
>> You are mistaken.  ;-)
>
> I am not mistaken.

That makes it pretty clear to me that this is a waste of everyone's time.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]