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?
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-
.