summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2022-08-12 23:51:15 (GMT)
committerGitHub <noreply@github.com>2022-08-12 23:51:15 (GMT)
commit7fe9c69024089c4a670eff506de7ebc63adecfdb (patch)
tree09f0eb268e54fb428127af5d20a0992e7e957244 /lib
parent125af816ae9f9ccfe7bbbbee2731bdaf5a70351e (diff)
parentae179a9c16aba4dc3b6adefd440c9b77bda1a785 (diff)
downloadlz4-7fe9c69024089c4a670eff506de7ebc63adecfdb.zip
lz4-7fe9c69024089c4a670eff506de7ebc63adecfdb.tar.gz
lz4-7fe9c69024089c4a670eff506de7ebc63adecfdb.tar.bz2
Merge pull request #1136 from t-mat/msvc-17.3
Support MSVC 2022 (version 17.3)
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4.c7
-rw-r--r--lib/lz4.h17
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 2a31735..654bfdf 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -524,7 +524,14 @@ LZ4_memcpy_using_offset(BYTE* dstPtr, const BYTE* srcPtr, BYTE* dstEnd, const si
case 2:
LZ4_memcpy(v, srcPtr, 2);
LZ4_memcpy(&v[2], srcPtr, 2);
+#if defined(_MSC_VER) && (_MSC_VER <= 1933) /* MSVC 2022 ver 17.3 or earlier */
+# pragma warning(push)
+# pragma warning(disable : 6385) /* warning C6385: Reading invalid data from 'v'. */
+#endif
LZ4_memcpy(&v[4], v, 4);
+#if defined(_MSC_VER) && (_MSC_VER <= 1933) /* MSVC 2022 ver 17.3 or earlier */
+# pragma warning(pop)
+#endif
break;
case 4:
LZ4_memcpy(v, srcPtr, 4);
diff --git a/lib/lz4.h b/lib/lz4.h
index c9a59e3..491c608 100644
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -311,10 +311,25 @@ LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcS
***********************************************/
typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
+/**
+ Note about RC_INVOKED
+
+ - RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is part of MSVC/Visual Studio).
+ https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros
+
+ - Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars)
+ and reports warning "RC4011: identifier truncated".
+
+ - To eliminate the warning, we surround long preprocessor symbol with
+ "#if !defined(RC_INVOKED) ... #endif" block that means
+ "skip this block when rc.exe is trying to read it".
+*/
+#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
LZ4LIB_API LZ4_stream_t* LZ4_createStream(void);
LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
+#endif
/*! LZ4_resetStream_fast() : v1.9.0+
* Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
@@ -398,10 +413,12 @@ typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
* creation / destruction of streaming decompression tracking context.
* A tracking context can be re-used multiple times.
*/
+#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
+#endif
/*! LZ4_setStreamDecode() :
* An LZ4_streamDecode_t context can be allocated once and re-used multiple times.