native way to tell if output binary is library or executable?
Jack
jckj33 at gmail.com
Mon Jan 18 16:55:41 UTC 2021
On Monday, 18 January 2021 at 03:30:56 UTC, Paul Backus wrote:
> On Monday, 18 January 2021 at 02:24:59 UTC, Jack wrote:
>> I know I can set version but I'd looking for a native way, if
>> any, to do that. Is possible to tell if output binary is
>> library or executable at compile time? then I'd call different
>> version of a function.
>
> Add `-version=library` to your compiler flags for the library
> and `-version=executable` to your compiler flags for the
> executable. Then, in the code, you can check for `version
> (library)` and `version (executable)`.
>
> Before you ask: no, there is no "more native" way to do this,
> because there is actually no difference in how the code is
> compiled between the two versions. The distinction between
> library and executable is only made when the compiled code is
> linked.
I'll really use this then. Thanks!
More information about the Digitalmars-d-learn
mailing list