자체 경고를 생성하는 외부 라이브러리 ProtocolBuffers를 사용하는 프로젝트의 디렉터리에서 모든 경고를 비활성화해야합니다.
다음은 내가받는 151 개의 경고 중 일부입니다.
my.pb.cc: warning C4512: 'google::protobuf::FatalException' : assignment operator could not be generated
my.pb.cc: warning C4244: 'initializing' : conversion from '__int64' to 'int', possible loss of data
my.pb.cc: warning C4125: decimal digit terminates octal escape sequence
my.pb.cc: warning C4127: conditional expression is constant
my.pb.cc
xutility(2132): warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS.
xutility
Visual Studio 포함 파일은 어디에 있습니까 ?
내 CMakeLists.txt 파일에 다음 줄을 추가하면 :
# Use a lower warning level threshold for autogenerated files
set(PROTOBUF_FILES_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/*.pb.*")
file(GLOB PROTOBUF_FILES ${PROTOBUF_FILES_PATH})
set_source_files_properties(${PROTOBUF_FILES} PROPERTIES COMPILE_FLAGS /W2)
생성 된 pb.cc
파일 에서 모든 경고가 비활성화되었지만 ProtoBuf의 내부 코드에서 다음 유형의 경고가 15 개 남아 있습니다.
my.pb.cc
xutility(2132): warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS.
ProtoBuf 자체를 수정할 수 없다는 것을 고려 -D_SCL_SECURE_NO_WARNINGS
하여 확장명이있는 파일에 대해서만 옵션을 추가하는 내 CMakeLists.txt 파일을 조정하여 이러한 마지막 경고를 비활성화하려면 어떻게 *.pb.*
해야합니까?
xutility
Protobuf가 어떻게 사용하는지 에 대해 잘 모르면 set_source_files_properties()
다음을 포함하도록 호출을 확장하는 것이 좋습니다 COMPILE_DEFINITIONS
.
set_source_files_properties(${PROTOBUF_FILES} PROPERTIES
COMPILE_DEFINITIONS _SCL_SECURE_NO_WARNINGS
COMPILE_FLAGS /W2
)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다