Skip to content

Commit

Permalink
On WIN32, fix compile errors on Clang using MSVC headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Rt39 committed Jul 10, 2024
1 parent e14acb9 commit 8d575db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/libFLAC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ if(FLAC__CPU_X86_64 OR FLAC__CPU_IA32)
if(WITH_AVX AND MSVC)
set_source_files_properties(fixed_intrin_avx2.c lpc_intrin_avx2.c stream_encoder_intrin_avx2.c lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS /arch:AVX2)
endif()
if(WITH_AVX AND WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Clang")
cmake_policy(PUSH)
cmake_policy(SET CMP0075 NEW)
check_include_file("unistd.h" HAVE_UNISTD_H)
if(NOT HAVE_UNISTD_H)
# Clang on Windows using MSVC headers
set_source_files_properties(fixed_intrin_avx2.c lpc_intrin_avx2.c stream_encoder_intrin_avx2.c lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS -mavx2)
endif()
cmake_policy(POP)
endif()
else()
check_cpu_arch_arm64(FLAC__CPU_ARM64)
if(FLAC__CPU_ARM64)
Expand Down
2 changes: 1 addition & 1 deletion src/share/getopt/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static char *posixly_correct;
/* Avoid depending on library functions or files
whose names are inconsistent. */

#ifndef getenv
#if !defined(getenv) && !(defined(__clang__) && defined(_MSC_VER))
extern char *getenv (const char * name);
#endif

Expand Down

0 comments on commit 8d575db

Please sign in to comment.