pragma(linkerDirective,_) removes double quotes, dmd ignores LIB
NonNull
non-null at use.startmail.com
Mon Nov 28 16:02:05 UTC 2022
On Monday, 28 November 2022 at 14:41:01 UTC, Adam D Ruppe wrote:
> This is the Microsoft doc page for the feature the pragma uses:
>
> https://learn.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?source=recommendations&view=msvc-170#linker
>
> It looks like they actually removed some options in the recent
> update, I know /SUBSYSTEM used to work there too but it is no
> longer listed and there's people on the web saying it stopped
> working after updating to the 2022 visual studio. So yeah I
> think they removed support for that.
>
> But /LIBPATH has never been supported as far as I know.
Aha! Thank you: the MS doc page is very informative. So
https://dlang.org/spec/pragma.html#linkerDirective
is not simply a mechanism that via the object file can get any
directive eventually to the linker as if on the command line.
I've been completely successful using pragma(lib,_) but looking
carefully I see that
https://dlang.org/spec/pragma.html#lib
contains highly significant clues under "implementation defined"
when compared to "implementation defined" under
https://dlang.org/spec/pragma.html#linkerDirective
--- pragma(lib,_) in effect guarantees to get the information
through to the linker. It is not restricted to MS-COFF, and is
not restricted to passing the information through the object file
but may use "other means" left unspecified.
--- pragma(linkerDirective,_) IS restricted in these ways as you
made clear.
So by comparison I should have realized, taking the hint
"restricted to MS-COFF" that the documentation for the MS linker
about what directives can be embedded in object files was
pertinent, because who knows what MS may permit?! The clues were
all there. But I didn't catch on. Sorry about the kerfuffle.
I have now successfully used pragma(lib,_) with a full path to
link what's needed without resorting to external build stuff. I
just need one pragma(lib,_) per library.
More information about the Digitalmars-d-learn
mailing list