Skip to content

Commit 6443fce

Browse files
author
Oleh Kulykov
committed
1722249865
1 parent 0391340 commit 6443fce

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ if (MSVC)
117117
else()
118118
message("MSVC undefined")
119119
endif()
120+
121+
# Run-Time Library
122+
# https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library
123+
message("Run-Time Library: ")
120124
if (LIBPLZMA_OPT_MSVC_MULTITHREAD_STATIC)
121125
if (CMAKE_BUILD_TYPE MATCHES Debug)
122126
message("Using Multithreaded Run-Time Debug Library(LIBCMTD.lib)")
@@ -146,10 +150,17 @@ if (MSVC)
146150

147151
if (LIBPLZMA_OPT_DISABLE_RUNTIME_TYPE_INFORMATION)
148152
# Disable Run-Time Type Information
153+
# Defined as 1 if the /GR (Enable Run-Time Type Information) compiler option is set. Otherwise, undefined.
154+
# When /GR is on, the compiler defines the _CPPRTTI preprocessor macro.
155+
# By default, /GR is on. /GR- disables run-time type information.
156+
# However, /GR increases the size of the .rdata sections of your image.
157+
# If your code does not use dynamic_cast or typeid, /GR- may produce a smaller image.
158+
# https://learn.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information
149159
# https://docs.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information
150160
# Check vs version: ?view=vs-2015
151161
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GR-")
152162
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
163+
add_definitions(-DLIBPLZMA_NO_CPP_RTTI=1)
153164
endif()
154165

155166
else()

src/plzma.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,20 @@
5858
# endif
5959
#elif defined(LIBPLZMA_MSC)
6060
// Defined as 1 if the /GR (Enable Run-Time Type Information) compiler option is set. Otherwise, undefined.
61+
// When /GR is on, the compiler defines the _CPPRTTI preprocessor macro.
62+
// By default, /GR is on. /GR- disables run-time type information.
63+
// However, /GR increases the size of the .rdata sections of your image.
64+
// If your code does not use dynamic_cast or typeid, /GR- may produce a smaller image.
65+
// https://learn.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information
6166
# if (defined(_CPPRTTI) && (_CPPRTTI > 0))
6267
# define RTTI_ENABLED 1
6368
# endif
6469
#endif
6570

71+
#if defined(RTTI_ENABLED) && defined(LIBPLZMA_NO_CPP_RTTI)
72+
# error "CMake rtti configuration error."
73+
#endif
74+
6675
plzma_path_timestamp plzma_path_timestamp_now(void) {
6776
plzma_path_timestamp t;
6877
t.last_access = t.last_modification = t.creation = ::time(NULL);
@@ -666,30 +675,30 @@ void plzma_item_out_stream_array_release(plzma_item_out_stream_array * LIBPLZMA_
666675

667676
#if 0
668677
void plzma_print_memory(int line, const void * LIBPLZMA_NULLABLE mem, const size_t len) {
669-
fprintf(stdout, "PRINT MEMORY AT LINE: %i, LEN: %llu\n", line, (unsigned long long)len);
678+
::fprintf(stdout, "PRINT MEMORY AT LINE: %i, LEN: %llu\n", line, (unsigned long long)len);
670679
if (!mem) {
671-
fprintf(stdout, "NULL\n");
672-
fflush(stdout);
680+
::fprintf(stdout, "NULL\n");
681+
::fflush(stdout);
673682
return;
674683
}
675684
char buff[256];
676685
char * s = buff;
677686
const uint8_t * umem = reinterpret_cast<const uint8_t *>(mem);
678687
bool hasoutput = false;
679688
for (size_t i = 0, j = 0; i < len; i++, j++) {
680-
int sp = sprintf(s, "0x%02x ", umem[i]);
689+
int sp = ::sprintf(s, "0x%02x ", umem[i]);
681690
s += sp;
682691
hasoutput = true;
683692
if (j == 10) {
684-
fprintf(stdout, "%s\n", buff);
693+
::fprintf(stdout, "%s\n", buff);
685694
j = 0;
686695
s = buff;
687696
hasoutput = false;
688697
}
689698
}
690699
if (hasoutput) {
691-
fprintf(stdout, "%s\n", buff);
700+
::fprintf(stdout, "%s\n", buff);
692701
}
693-
fflush(stdout);
702+
::fflush(stdout);
694703
}
695704
#endif // #if 0

0 commit comments

Comments
 (0)