From 3f70562bbbc217d292c745143b07f9139a6a6f0b Mon Sep 17 00:00:00 2001 From: conceptgenesis Date: Sat, 30 Jan 2016 14:40:44 -0800 Subject: [PATCH] Fix WebRtc ninja x86 build using Visual Studio 2015 (set GYP_MSVS_VERSION=2015). Visual Studio 2015 balks at the implicit truncation of values. Easily fixed with an explicit cast. Fixed redefinition of CLOCKS_PER_SEC when using Visual Studio 2015 and the Windows 10 SDK. CLOCKS_PER_SEC is also defined in "\include\10.0.10240.0\ucrt\time.h" and also has the value of 1000 Hiding snprintf definition if building with Visual Studio 2015 Fixed C4573 compiler complaint in audio_processing_impl_locking_unittest.cc. BUG=webrtc:5183 Review URL: https://codereview.webrtc.org/1412653006 Cr-Commit-Position: refs/heads/master@{#11434} --- AUTHORS | 5 +++-- webrtc/base/logging.cc | 2 ++ .../isac/main/test/ReleaseTest-API/ReleaseTest-API.cc | 2 ++ .../audio_coding/codecs/isac/main/test/simpleKenny.c | 4 +++- .../audio_processing_impl_locking_unittest.cc | 8 ++++++-- .../audio_processing/transient/file_utils_unittest.cc | 6 +++--- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6f11ee66d8..e9e9d662f2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,12 +1,14 @@ -# Names should be added to this file like so: +# Names should be added to this file like so: # Name or Organization +Alexander Brauckmann Andrew MacDonald Anil Kumar Ben Strong Bob Withers Bridger Maxwell Christophe Dumez +Cody Barnes Colin Plumb Eric Rescorla, RTFM Inc. Giji Gangadharan @@ -32,7 +34,6 @@ Silviu Caragea Steve Reid Vicken Simonian Victor Costan -Alexander Brauckmann &yet LLC Agora IO diff --git a/webrtc/base/logging.cc b/webrtc/base/logging.cc index 686b9b2b02..019a31623b 100644 --- a/webrtc/base/logging.cc +++ b/webrtc/base/logging.cc @@ -13,7 +13,9 @@ #define WIN32_LEAN_AND_MEAN #endif #include +#if _MSC_VER < 1900 #define snprintf _snprintf +#endif #undef ERROR // wingdi.h #endif diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc b/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc index 4cef8f7b3b..a734bb0643 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc +++ b/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc @@ -33,8 +33,10 @@ //#define FS 16000 /* sampling frequency (Hz) */ #ifdef WIN32 +#ifndef CLOCKS_PER_SEC #define CLOCKS_PER_SEC 1000 /* Runtime statistics */ #endif +#endif using namespace std; diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c b/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c index e8116ffdf8..1a1697fdae 100644 --- a/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c +++ b/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c @@ -17,8 +17,10 @@ #ifdef WIN32 #include "windows.h" +#ifndef CLOCKS_PER_SEC #define CLOCKS_PER_SEC 1000 #endif +#endif #include #include @@ -218,7 +220,7 @@ int main(int argc, char* argv[]) { _makepath(bitrateFileName, outDrive, outPath, "bitrate", ".txt"); bitrateFile = fopen(bitrateFileName, "a"); - fprintf(bitrateFile, "% %%s \n", inname); + fprintf(bitrateFile, "%% %s \n", inname); #endif printf("\n"); diff --git a/webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc index 3d2c71fb2d..2e22b2c51e 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl_locking_unittest.cc @@ -198,8 +198,12 @@ struct TestConfig { AecType::BasicWebRtcAecSettingsWithDelayAgnosticAec, AecType::BasicWebRtcAecSettingsWithAecMobile}; for (auto test_config : in) { - for (auto aec_type : aec_types) { - test_config.aec_type = aec_type; + // Due to a VisualStudio 2015 compiler issue, the internal loop + // variable here cannot override a previously defined name. + // In other words "type" cannot be named "aec_type" here. + // https://connect.microsoft.com/VisualStudio/feedback/details/2291755 + for (auto type : aec_types) { + test_config.aec_type = type; out.push_back(test_config); } } diff --git a/webrtc/modules/audio_processing/transient/file_utils_unittest.cc b/webrtc/modules/audio_processing/transient/file_utils_unittest.cc index 7fb7d2d6a9..b8d532f3a4 100644 --- a/webrtc/modules/audio_processing/transient/file_utils_unittest.cc +++ b/webrtc/modules/audio_processing/transient/file_utils_unittest.cc @@ -419,9 +419,9 @@ TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) { rtc::scoped_ptr written_buffer(new float[kBufferLength]); rtc::scoped_ptr read_buffer(new float[kBufferLength]); - written_buffer[0] = kPi; - written_buffer[1] = kE; - written_buffer[2] = kAvogadro; + written_buffer[0] = static_cast(kPi); + written_buffer[1] = static_cast(kE); + written_buffer[2] = static_cast(kAvogadro); EXPECT_EQ(kBufferLength, WriteFloatBufferToFile(file.get(), kBufferLength,