Reputation: 4790
I am trying to use the /GUARD:CD
MSVC flag. From the documentation, it says
The
/GUARD:CF
option must be specified to both the compiler and linker
The documentation also says that /GUARD:CF
requires the /DYNAMICBASE
option to also be set.
However, when I try to compile, I see warnings for unrecognized options:
cl -c /W3 /O2 /EHsc /MP /Zi /nologo /MD /Zi /DUNICODE /D_UNICODE /D_CRT_SECURE_NO_DEPRECATE /LD -Isrc -Iimport/include -D_WINDOWS -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL /GS /DYNAMICBASE /GUARD:CF /Fo: redacted.cpp.obj redacted.cpp cl : Command line warning D9002 : ignoring unknown option '/GU' cl : Command line warning D9002 : ignoring unknown option '/GD' cl : Command line warning D9002 : ignoring unknown option '/G:' cl : Command line warning D9002 : ignoring unknown option '/GC'
At first I thought maybe I accidentally introduced non-printable characters in my text editor, but I verified with cat --show-nonprinting
that that was not the case.
How can I correctly pass /GUARD:CF
to the MSVC cl
compiler so that it recognizes it?
Upvotes: 1
Views: 1405
Reputation: 38824
The page you linked is a part of the manual to MSVC linker options. Linker options are case-insensitive. That page has a link to the manual to MSVC compiler options:
When source code is compiled by using the /guard:cf option.
Compiler options are case-sensitive. The proper cl invocation
cl -c /W3 /O2 /EHsc /MP /Zi /nologo /MD /Zi /DUNICODE /D_UNICODE /D_CRT_SECURE_NO_DEPRECATE /LD -Isrc -Iimport/include -D_WINDOWS -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL /GS /DYNAMICBASE /guard:cf /Fo: redacted.cpp.obj redacted.cpp
Just to know. Disabling guard is different for the linker and the compiler: /GUARD:NO
and /guard:cf-
.
Upvotes: 2
Reputation: 51874
The documentation you linked (which is about the linker /GUARD
option) is rather misleading, but the answer is buried in there, if you look really hard:
For the compiler, the command-line option needs to be in lowercase (but the linker seems to accept either uppercase or lowercase).
So, use /guard:cf
instead of /GUARD:CF
on the cl
command-line.
From the linked document:
When source code is compiled by using the /guard:cf option, …
And, on the page that the /guard:cf
links to, the switch is only ever given in lowercase.
Upvotes: 1