On 3/24/2011 4:07 AM, bearophile wrote:
I receive an error like:

OPTLINK (R) for Win32  Release 8.00.12 Copyright (C) Digital Mars 1989-2010
All rights reserved. http://www.digitalmars.com/ctg/optlink.html ...   Offset
00137H Record Type 00C3 Error 1: Previous Definition Different : __Dmain ---
errorlevel 1

No mystery there. You have two main()'s. There can be only one.


Currently in D there is no notion of "main module",

Yes, there is. It's the one that defines main().


I like to keep a main() in most modules, even the ones that are usually not
supposed to be the main modules of a program, because I put in their main()
some demo code that shows what this module does (and a main is useful to run
unittests too, rdmd has the --main switch for this). Most of my Python
modules have such demo main code, that runs only if you run them as main
modules.

That's what the version statement is for:

version (My_Demo)
{
    void main()
    {
        ...
    }
}

There's no reason to add more features to duplicate that.

Reply via email to