No main() Error

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Wed Feb 5 05:34:09 UTC 2025


On 05/02/2025 8:41 AM, 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?

The compiler doesn't need to do anything extra.

All linkers can and will error if the start address / main function is 
missing.

What you are asking for is a nice customized error message for D.

Which as far as I'm aware is not supported by any linker.



More information about the dip.ideas mailing list