No main() Error

monkyyy crazymonkyyy at gmail.com
Tue Feb 4 19:57:18 UTC 2025


On Tuesday, 4 February 2025 at 19:41:09 UTC, Ron Tarrant wrote:
> On Tuesday, 4 February 2025 at 09:25:14 UTC, Richard (Rikki) 
> Andrew Cattermole wrote:
>> On 04/02/2025 10:20 PM, Richard (Rikki) Andrew Cattermole 
>> wrote:
>>> Syntax does not play a role in this.
>>
>> I should clarify this, the compiler already has functions for 
>> checking if a function is a main function.
>>
>> https://github.com/dlang/dmd/blob/89b93e8b0952e8bf5dd73020a23cd7cb1897adcb/compiler/src/dmd/func.d#L595
>>
>> It looks like it can work without semantic analysis having 
>> been done too.
>
> Thanks for the clarification.
>
> I confess I know nothing about compiler/linker design.
>
> Is it possible for the compiler, having read the code file, to 
> pass along enough information to the linker so it knows that a) 
> there is no `main()` function in the code file and b) the 
> current build isn't a library, thus making it possible for the 
> linker to inform the user in clearer language that something's 
> off?
changing the c abi isnt really on the table without replacing 
entire os's
youd be better off writing a "rdmd" clone that attempts to run 
the file if it gets the error places and top level statements in 
a main function



More information about the dip.ideas mailing list