Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 10, 2012 #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
Attachments:
| Does D support some sort of #pragma lib? I use this in C all the time, and I really like code that auto-links its dependencies. Maintaining a massive list of arbitrary libs in my build scripts is a pain, and even more so when the code that depends on it may be version-ed out on particular configurations. Syncing the build scripts against the state of the code is tedious. |
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On 10/10/2012 1:22 AM, Manu wrote:
> Does D support some sort of #pragma lib?
Yes:
pragma(lib, "mylib.lib");
|
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright Attachments:
| Percect, thanks!
On 10 October 2012 11:27, Walter Bright <newshound2@digitalmars.com> wrote:
> On 10/10/2012 1:22 AM, Manu wrote:
>
>> Does D support some sort of #pragma lib?
>>
>
> Yes:
>
> pragma(lib, "mylib.lib");
>
|
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
On 10 October 2012 09:31, Manu <turkeyman@gmail.com> wrote: > Percect, thanks! > > > On 10 October 2012 11:27, Walter Bright <newshound2@digitalmars.com> wrote: >> >> On 10/10/2012 1:22 AM, Manu wrote: >>> >>> Does D support some sort of #pragma lib? >> >> >> Yes: >> >> pragma(lib, "mylib.lib"); > > NB: GCC has no such equivalent, and IMO libraries should be specified during the linking step. Such information simply doesn't belong inside a source file as a source file can be compiled or assembled even without a linking stage. Regards, -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; |
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
Attachments:
| On 10 October 2012 14:15, Iain Buclaw <ibuclaw@ubuntu.com> wrote:
> On 10 October 2012 09:31, Manu <turkeyman@gmail.com> wrote:
> > Percect, thanks!
> >
> >
> > On 10 October 2012 11:27, Walter Bright <newshound2@digitalmars.com>
> wrote:
> >>
> >> On 10/10/2012 1:22 AM, Manu wrote:
> >>>
> >>> Does D support some sort of #pragma lib?
> >>
> >>
> >> Yes:
> >>
> >> pragma(lib, "mylib.lib");
> >
> >
>
> NB: GCC has no such equivalent, and IMO libraries should be specified during the linking step. Such information simply doesn't belong inside a source file as a source file can be compiled or assembled even without a linking stage.
>
Really? Is it an MS thing? I'm amazed the other compilers haven't adopted
that in the last 10 years or whatever.
It just leaves a note in the object file that the linker happens to find
and apply later. I don't see any problem with it. It's the source file has
the dependency on the lib, it's annoying to manually manage that externally
when the dependency is already explicit in the code, and can be easily
recorded in the object file.
I think D's modules make this relationship even stronger, and it's a shame
it's not a standard part of D.
|
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Wednesday, 10 October 2012 at 11:50:29 UTC, Manu wrote:
> On 10 October 2012 14:15, Iain Buclaw <ibuclaw@ubuntu.com> wrote:
>
>> On 10 October 2012 09:31, Manu <turkeyman@gmail.com> wrote:
>> > Percect, thanks!
>> >
>> >
>> > On 10 October 2012 11:27, Walter Bright <newshound2@digitalmars.com>
>> wrote:
>> >>
>> >> On 10/10/2012 1:22 AM, Manu wrote:
>> >>>
>> >>> Does D support some sort of #pragma lib?
>> >>
>> >>
>> >> Yes:
>> >>
>> >> pragma(lib, "mylib.lib");
>> >
>> >
>>
>> NB: GCC has no such equivalent, and IMO libraries should be specified
>> during the linking step. Such information simply doesn't belong inside
>> a source file as a source file can be compiled or assembled even
>> without a linking stage.
>>
>
> Really? Is it an MS thing? I'm amazed the other compilers haven't adopted
> that in the last 10 years or whatever.
Yes, it is a Microsoft extension. I never saw it in any other C or C++ compiler.
Maybe Intel and CodeGear compilers have it, since they value MSVC compatibility.
--
Paulo
|
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Iain Buclaw | On 2012-10-10 13:15, Iain Buclaw wrote: > NB: GCC has no such equivalent, and IMO libraries should be specified > during the linking step. Such information simply doesn't belong inside > a source file as a source file can be compiled or assembled even > without a linking stage. I agree, I think a package manager together with a build tool should be used instead. -- /Jacob Carlborg |
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg Attachments:
| On 10 October 2012 15:42, Jacob Carlborg <doob@me.com> wrote:
> On 2012-10-10 13:15, Iain Buclaw wrote:
>
> NB: GCC has no such equivalent, and IMO libraries should be specified
>> during the linking step. Such information simply doesn't belong inside a source file as a source file can be compiled or assembled even without a linking stage.
>>
>
> I agree, I think a package manager together with a build tool should be used instead.
None of those things actually embody the information about the
relationship, nor can they. The source code does, and nothing else.
Features that imply the dependency may (and often are) be disabled at
compile time.
I rather like that the compiler is able to put a note in the object file
that it depends on a particular lib, because it does.
I'm not sure how a package manager helps... What is a package manager? ;)
I'd like to hear some reasons why that is a bad or undesirable thing, or is
this just an opinion?
|
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
On 10 October 2012 13:59, Manu <turkeyman@gmail.com> wrote: > On 10 October 2012 15:42, Jacob Carlborg <doob@me.com> wrote: >> >> On 2012-10-10 13:15, Iain Buclaw wrote: >> >>> NB: GCC has no such equivalent, and IMO libraries should be specified during the linking step. Such information simply doesn't belong inside a source file as a source file can be compiled or assembled even without a linking stage. >> >> >> I agree, I think a package manager together with a build tool should be used instead. > > > None of those things actually embody the information about the relationship, > nor can they. The source code does, and nothing else. Features that imply > the dependency may (and often are) be disabled at compile time. > I rather like that the compiler is able to put a note in the object file > that it depends on a particular lib, because it does. > I'm not sure how a package manager helps... What is a package manager? ;) > I'd like to hear some reasons why that is a bad or undesirable thing, or is > this just an opinion? IIRC the toolchain used by Visual Studio *always* performs linking, so that is why this is not a problem for MSVC. To embody the information about the relationship in the object file, one must be able to embody the information about the relationship in the assembler file. And last time I checked there is no assembly syntax for '#pragma lib'. Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; |
October 10, 2012 Re: #pragma comment (lib, ...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Wednesday, 10 October 2012 at 13:23:57 UTC, Manu wrote:
> On 10 October 2012 15:42, Jacob Carlborg <doob@me.com> wrote:
>
>> On 2012-10-10 13:15, Iain Buclaw wrote:
>>
>> NB: GCC has no such equivalent, and IMO libraries should be specified
>>> during the linking step. Such information simply doesn't belong inside
>>> a source file as a source file can be compiled or assembled even
>>> without a linking stage.
>>>
>>
>> I agree, I think a package manager together with a build tool should be
>> used instead.
>
>
> None of those things actually embody the information about the
> relationship, nor can they. The source code does, and nothing else.
> Features that imply the dependency may (and often are) be disabled at
> compile time.
> I rather like that the compiler is able to put a note in the object file
> that it depends on a particular lib, because it does.
> I'm not sure how a package manager helps... What is a package manager? ;)
> I'd like to hear some reasons why that is a bad or undesirable thing, or is
> this just an opinion?
This only works if it is part of the language definition.
In C and C++ case I am usually against it, because I favour portability over dependencies to a specific compiler vendor. Many years of writing multi-platform code do leave some scars.
As for D, if this can be made part of the language then I see no big reason against it.
--
Paulo
|
Copyright © 1999-2021 by the D Language Foundation