Koz Ross
Koz Ross

Reputation: 3140

GDC equivalent to dmd's -main option

Does the GNU D Compiler provide a flag similar to the -main flag of dmd? I've checked the options list for both GCC itself and gdmd (designed to take similar arguments to dmd, but use gdc instead), and couldn't find anything like it.

If such a flag exists, what can I do to get similar behaviour?

Upvotes: 1

Views: 104

Answers (2)

ARaspiK
ARaspiK

Reputation: 165

GDMD does contain a -main argument. What version are you using?
From GDMD D Compiler 2.068 using gdc (Gentoo 8.1.0 p1.2) 8.1.0:

Usage:
  ...
  -main        add default main() (e.g for unittesting)

It works on my machine, and it should too on yours. Please use an updated GDMD.

Upvotes: 0

Panke
Panke

Reputation: 186

You could create a module that contains a main function guarded by a version block.

version(emitMain) void main() {} 

If you would normally use '-main', now use '-version=emitMain'. This way your build system does not have to take care of not including this module for your normal builds that already have a main function.

Upvotes: 1

Related Questions