www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compiler switches in source code

reply Vinod K Chandran <kcvinu82 gmail.com> writes:
Why Compiler Writers Accept instructions for the compiler as 
compiler switches rather than through the source code. What's 
wrong with providing options like "L/SUBSYSTEM:WINDOWS" through 
the source code?
Feb 13
next sibling parent Daniel N <no public.email> writes:
On Sunday, 14 February 2021 at 07:56:43 UTC, Vinod K Chandran 
wrote:
 Why Compiler Writers Accept instructions for the compiler as 
 compiler switches rather than through the source code. What's 
 wrong with providing options like "L/SUBSYSTEM:WINDOWS" through 
 the source code?
You are in luck, dmd does provide support for this... https://dlang.org/spec/pragma.html#linkerDirective ... and it's wonderful, I wish all compilers followed suit.
Feb 14
prev sibling next sibling parent reply kinke <noone nowhere.com> writes:
https://dlang.org/spec/pragma.html#linkerDirective
Feb 14
parent Vinod K Chandran <kcvinu82 gmail.com> writes:
On Sunday, 14 February 2021 at 08:41:15 UTC, kinke wrote:
 https://dlang.org/spec/pragma.html#linkerDirective
Thanks kinke. Let me check.
Feb 14
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 2/13/2021 11:56 PM, Vinod K Chandran wrote:
 Why Compiler Writers Accept instructions for the compiler as compiler switches 
 rather than through the source code. What's wrong with providing options like 
 "L/SUBSYSTEM:WINDOWS" through the source code?
There are a couple pragmas that do it https://dlang.org/spec/pragma.html#linkerDirective but people generally prefer to do those with their build system.
Feb 14
parent reply Vinod K Chandran <kcvinu82 gmail.com> writes:
On Sunday, 14 February 2021 at 08:59:32 UTC, Walter Bright wrote:
 On 2/13/2021 11:56 PM, Vinod K Chandran wrote:
 Why Compiler Writers Accept instructions for the compiler as 
 compiler switches rather than through the source code. What's 
 wrong with providing options like "L/SUBSYSTEM:WINDOWS" 
 through the source code?
There are a couple pragmas that do it https://dlang.org/spec/pragma.html#linkerDirective but people generally prefer to do those with their build system.
Thanks Walter Bright So I can write like this -- pragma(linkerDirective, "L/SUBSYSTEM:WINDOWS") Am i right ? If so, i would like to know more about like which compiler switches are allowed to use with pragmas.
Feb 14
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 2/14/2021 8:58 AM, Vinod K Chandran wrote:
 So I can write like this --
 pragma(linkerDirective, "L/SUBSYSTEM:WINDOWS")
 Am i right ?
yes
 If so, i would like to know more about like which compiler switches 
 are allowed to use with pragmas.
https://dlang.org/spec/pragma.html The linkerDirective, however, is for linker switches.
Feb 14
parent reply Vinod K Chandran <kcvinu82 gmail.com> writes:
On Sunday, 14 February 2021 at 22:26:54 UTC, Walter Bright wrote:
 On 2/14/2021 8:58 AM, Vinod K Chandran wrote:

 yes
Thanks for the reply.
 https://dlang.org/spec/pragma.html
I had already read that page.
 The linkerDirective, however, is for linker switches.
I would like to know how compiler switches like "-i", "-j" are using in "pragma"
Feb 14
parent reply Mike Parker <aldacron gmail.com> writes:
On Monday, 15 February 2021 at 07:32:06 UTC, Vinod K Chandran 
wrote:


 I would like to know how compiler switches like "-i", "-j" are 
 using in "pragma"
There is no pragma for those switches.
Feb 14
parent Vinod K Chandran <kcvinu82 gmail.com> writes:
On Monday, 15 February 2021 at 07:46:55 UTC, Mike Parker wrote:

 I would like to know how compiler switches like "-i", "-j" are 
 using in "pragma"
There is no pragma for those switches.
Thanks Mike Parker. And special thanks for the book "Learning D".
Feb 15
prev sibling parent reply Petar Kirov [ZombineDev] <petar.p.kirov gmail.com> writes:
On Sunday, 14 February 2021 at 07:56:43 UTC, Vinod K Chandran 
wrote:
 Why Compiler Writers Accept instructions for the compiler as 
 compiler switches rather than through the source code. What's 
 wrong with providing options like "L/SUBSYSTEM:WINDOWS" through 
 the source code?
I think rund [1] offers what you're looking for. Give it a try and let us know what you think! [1]: https://github.com/dragon-lang/rund
Feb 15
next sibling parent Vinod K Chandran <kcvinu82 gmail.com> writes:
On Monday, 15 February 2021 at 08:40:44 UTC, Petar Kirov 
[ZombineDev] wrote:

 I think rund [1] offers what you're looking for. Give it a try 
 and let us know what you think!

 [1]: https://github.com/dragon-lang/rund
Thanks Petar Kirov [ZombineDev]. Let me try it.
Feb 15
prev sibling parent reply Vinod K Chandran <kcvinu82 gmail.com> writes:
On Monday, 15 February 2021 at 08:40:44 UTC, Petar Kirov 
[ZombineDev] wrote:

 [1]: https://github.com/dragon-lang/rund
Hi, I just installed it successfully. But I am little bit confused about the usage. There are some examples under the heading "Idea". Do i need to use the "Config" data type ?
Feb 15
parent Jonathan Marler <johnnymarler gmail.com> writes:
On Monday, 15 February 2021 at 14:28:36 UTC, Vinod K Chandran 
wrote:
 On Monday, 15 February 2021 at 08:40:44 UTC, Petar Kirov 
 [ZombineDev] wrote:

 [1]: https://github.com/dragon-lang/rund
Hi, I just installed it successfully. But I am little bit confused about the usage. There are some examples under the heading "Idea". Do i need to use the "Config" data type ?
This is the section you're looking for: https://github.com/dragon-lang/rund#source-compiler-directives
Feb 16