rdmd --main

"Jérôme M. Berger" jeberger at free.fr
Wed Nov 24 10:29:42 PST 2010


Andrei Alexandrescu wrote:
> On 11/22/10 12:53 PM, spir wrote:
>> Hello,
>>
>>
>> The rdmd option --main is really helpful to test modules independently
>> (it adds an empty main() to prevent the linker from crying). An issue
>> is that each time we switch between .d files that have no main()
>> (modules in tended for export) and app files that have one, this
>> option must be set or removed (else the linker complains for having 2
>> main()).
>> This is not very practicle for rapid edit-test cycles -- for
>> "exploratory" programming in general. Would it be difficult for rdmd
>> to detect whether a main is already present? It is not a big issue
>> anyway -- just in case would be easy.
> 
> That feature could be added in several ways.
> 
> 1. Cooperate with the compiler - have the compiler detect whether or not
> main() exists.
> 
> 2. Write a tokenizer (parser is not really needed) and have it identify
> the occurrence of main with one of the appropriate signatures at top level.
> 
> 3. Use compiler's json output.
> 
> 4. Use a low-tech search such as sed to find main.
> 
5. Put the main function in a library and link it with -l. I'm not
sure if this would work with optlink but it does work with gnu ld.

		Jerome
-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101124/fc730331/attachment.pgp>


More information about the Digitalmars-d mailing list