rdmd & exception def & multiple files

Charles Hixson charleshixsn at earthlink.net
Wed Aug 29 16:09:41 PDT 2012


On 08/29/2012 03:47 PM, Charles Hixson wrote:
> On 08/29/2012 01:36 PM, Dmitry Olshansky wrote:
>> On 30-Aug-12 00:14, Charles Hixson wrote:
>>> Is the following expected?
>>> When I put the exception:
>>> class LogicError : Exception
>>> {
>>> this( string file = __FILE__, size_t line = __LINE__, Throwable
>>> next = null )
>>> {
>>> super( "Internal logic error", file, line, next );
>>> }
>>> }
>>>
>>> In the same file as the rest of the program,
>>> rdmd --main -unittest avl.d
>>> had no trouble with it, but when I put it in a separate file,
>>> while:
>>> dmd -c -unittest avl.d utils.d
>>> accepted it without complaint, rdmd responded with:
>>> rdmd --main -unittest avl.d utils.d
>>
>> It should work with plain rdmd --main -unittest avl.d that's the whole
>> point of rdmd actually.
>>
> You were right. That worked. Where should I look to better understand
> rdmd? I expected to need to list all the local files that were needed,
> but clearly that's the wrong approach.

Well, it worked until I started "depending on it".  Then it stopped.
So I guess that, at least for exceptions, they need to be defined within 
the same file that they are used for rdmd to be happy with them, though 
clearly that's not true for the standard libraries.  And I don't know 
where the boundaries are.

This is particularly weird, because when I try to create a simple 
example case it doesn't display the problem.  Not too surprisingly it 
depends on the presence of the unittest parameter, though even that's a 
little surprising as I haven't yet added any unit tests.  Still, without 
the unittest it isn't even thinking of executing anything.

Still, for some reason if the exception is defined in a separate file 
(utils.d) it can't find the symbol.  I even tried including utils.o 
instead of utils.d.  No change.

FWIW, I invoke the exception with:
default:
	assert	(false, "internal logic error");
	throw	new	LogicError ();
in a few places.  As I said, I haven't written the unittests yet, so 
even the assert has never been called.  Still, that's a consideration 
that happens much after linking.


More information about the Digitalmars-d-learn mailing list