digitalmars.D.learn - native way to tell if output binary is library or executable?
- Jack (4/4) Jan 17 2021 I know I can set version but I'd looking for a native way, if
- Paul Backus (10/14) Jan 17 2021 Add `-version=library` to your compiler flags for the library and
- Jack (2/16) Jan 18 2021 I'll really use this then. Thanks!
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.
Jan 17 2021
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.
Jan 17 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'll really use this then. Thanks!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.
Jan 18 2021