June 11, 2006
Derek Parnell wrote:
> On Mon, 12 Jun 2006 00:31:42 +1000, Bruno Medeiros <brunodomedeirosATgmail@SPAM.com> wrote:
> 
>> Sean Kelly wrote:
>>>  This would actually address a problem I noticed with Build in that it isn't able to detect if a module is a "header" module and will compile and link the code in anyway, which produces "previous definition different" errors at link time.
>>>   Sean
>>
>> Hum, Have you used build exclusions (option -X) in order not to compile and link a module?
>>
> 
> I think that the best option for now is to use
> 
>   version(build) pragma(nolink);
> 
> This will ensure that the file containing this pragma is not compiled or linked.

Yup.  This is what I've been doing.


Sean
June 11, 2006
Sean Kelly wrote:
> Derek Parnell wrote:
>> On Mon, 12 Jun 2006 00:31:42 +1000, Bruno Medeiros <brunodomedeirosATgmail@SPAM.com> wrote:
>>
>>> Sean Kelly wrote:
>>>>  This would actually address a problem I noticed with Build in that it isn't able to detect if a module is a "header" module and will compile and link the code in anyway, which produces "previous definition different" errors at link time.
>>>>   Sean
>>>
>>> Hum, Have you used build exclusions (option -X) in order not to compile and link a module?
>>>
>>
>> I think that the best option for now is to use
>>
>>   version(build) pragma(nolink);
>>
>> This will ensure that the file containing this pragma is not compiled or linked.
> 
> Yup.  This is what I've been doing.
> 
> 
> Sean

Then what you meant about Build "isn't able to detect if a module is a "header" module" ?


-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
June 11, 2006
Bruno Medeiros wrote:
> Sean Kelly wrote:
>> Derek Parnell wrote:
>>> On Mon, 12 Jun 2006 00:31:42 +1000, Bruno Medeiros <brunodomedeirosATgmail@SPAM.com> wrote:
>>>
>>>> Sean Kelly wrote:
>>>>>  This would actually address a problem I noticed with Build in that it isn't able to detect if a module is a "header" module and will compile and link the code in anyway, which produces "previous definition different" errors at link time.
>>>>>   Sean
>>>>
>>>> Hum, Have you used build exclusions (option -X) in order not to compile and link a module?
>>>>
>>>
>>> I think that the best option for now is to use
>>>
>>>   version(build) pragma(nolink);
>>>
>>> This will ensure that the file containing this pragma is not compiled or linked.
>>
>> Yup.  This is what I've been doing.
> 
> Then what you meant about Build "isn't able to detect if a module is a "header" module" ?

It isn't able to by itself--you have to tell it.  And while I'm not certain DMD could do better, I'd like to believe so.  That was my only point.  That in the long term it may be more useful to have such features built directly into the compiler.  In my brief experience with Build it's a darn sight better than generating C-style libraries.  And I suspect it will get around the template linking issues I've run into to boot.


Sean
June 11, 2006
Sean Kelly wrote:
> Bruno Medeiros wrote:
>>
>> Then what you meant about Build "isn't able to detect if a module is a "header" module" ?
> 
> It isn't able to by itself--you have to tell it.  And while I'm not certain DMD could do better, I'd like to believe so.  That was my only point.  That in the long term it may be more useful to have such features built directly into the compiler.  In my brief experience with Build it's a darn sight better than generating C-style libraries.  And I suspect it will get around the template linking issues I've run into to boot.
> 
> 
> Sean

How could Build, or *any* tool at all, know by itself if a D file is to be compiled or not? I don't think it's possible, unless the file extension is ".di".

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
June 11, 2006
On Mon, 12 Jun 2006 05:55:18 +1000, Sean Kelly <sean@f4.ca> wrote:


>>  Then what you meant about Build "isn't able to detect if a module is a "header" module" ?
>
> It isn't able to by itself--you have to tell it.  And while I'm not certain DMD could do better, I'd like to believe so.

The problem as I see it is how any anyone or anything know that a module is a 'hesder' module. The only two clear cut signals are a module that has *zero* implementation details or the module is presented as a .di file. The first signal could be detectable by Build and the second one currently is. But that doesn't handle other 'header' modules that don't fit into these two categories. That is why I adopted the simple method of having the coder put in the pragma to identify a module as a 'header' type.

Can you give me the algorithm to use to detect that a module is a 'header' or not? Maybe if I had such an algorithm I might be able to implement it.
-- 
Derek Parnell
Melbourne, Australia
June 12, 2006
Derek Parnell wrote:
> 
> Can you give me the algorithm to use to detect that a module is a 'header' or not? Maybe if I had such an algorithm I might be able to implement it.

It probably isn't possible to come up with a general solution.  But I imagined that if the compiler could determine that no object level code generation were required (ie. the module contained only type definitions and inlinable code) then it could be assumed to be a header.  But of course what's inlined varies from compiler to compiler, and then there's the issue of static ctors for structs and such.  Being aware of .di files as build is now is probably the best and easiest solution.


Sean
1 2
Next ›   Last »