Remove COMPILE_ASSERT and use static_assert everywhere
COMPILE_ASSERT is no longer needed now that we have C++11's static_assert. R=aluebs@webrtc.org, andrew@webrtc.org, hellner@chromium.org, henrike@webrtc.org Review URL: https://webrtc-codereview.appspot.com/39469004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8058 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
86e1e487e7
commit
2ebfac5649
@ -78,7 +78,6 @@
|
||||
#include "third_party/libyuv/include/libyuv/video_common.h"
|
||||
#include "webrtc/base/bind.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/base/messagequeue.h"
|
||||
#include "webrtc/base/ssladapter.h"
|
||||
@ -249,11 +248,11 @@ static JNIEnv* AttachCurrentThreadIfNeeded() {
|
||||
// because the alternative (of silently passing a 32-bit pointer to a vararg
|
||||
// function expecting a 64-bit param) picks up garbage in the high 32 bits.
|
||||
static jlong jlongFromPointer(void* ptr) {
|
||||
COMPILE_ASSERT(sizeof(intptr_t) <= sizeof(jlong),
|
||||
Time_to_rethink_the_use_of_jlongs);
|
||||
static_assert(sizeof(intptr_t) <= sizeof(jlong),
|
||||
"Time to rethink the use of jlongs");
|
||||
// Going through intptr_t to be obvious about the definedness of the
|
||||
// conversion from pointer to integral type. intptr_t to jlong is a standard
|
||||
// widening by the COMPILE_ASSERT above.
|
||||
// widening by the static_assert above.
|
||||
jlong ret = reinterpret_cast<intptr_t>(ptr);
|
||||
assert(reinterpret_cast<void*>(ret) == ptr);
|
||||
return ret;
|
||||
|
@ -106,7 +106,6 @@ static_library("rtc_base_approved") {
|
||||
sources = [
|
||||
"checks.cc",
|
||||
"checks.h",
|
||||
"compile_assert.h",
|
||||
"exp_filter.cc",
|
||||
"exp_filter.h",
|
||||
"md5.cc",
|
||||
|
@ -41,7 +41,6 @@
|
||||
'sources': [
|
||||
'checks.cc',
|
||||
'checks.h',
|
||||
'compile_assert.h',
|
||||
'exp_filter.cc',
|
||||
'exp_filter.h',
|
||||
'md5.cc',
|
||||
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// Borrowed from Chromium's src/base/macros.h.
|
||||
|
||||
#ifndef WEBRTC_BASE_COMPILE_ASSERT_H_
|
||||
#define WEBRTC_BASE_COMPILE_ASSERT_H_
|
||||
|
||||
// The COMPILE_ASSERT macro can be used to verify that a compile time
|
||||
// expression is true. For example, you could use it to verify the
|
||||
// size of a static array:
|
||||
//
|
||||
// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
|
||||
// content_type_names_incorrect_size);
|
||||
//
|
||||
// or to make sure a struct is smaller than a certain size:
|
||||
//
|
||||
// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
|
||||
//
|
||||
// The second argument to the macro is the name of the variable. If
|
||||
// the expression is false, most compilers will issue a warning/error
|
||||
// containing the name of the variable.
|
||||
|
||||
// TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and
|
||||
// libjingle are merged.
|
||||
#if !defined(COMPILE_ASSERT)
|
||||
#if __cplusplus >= 201103L
|
||||
// Under C++11, just use static_assert.
|
||||
#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
|
||||
|
||||
#else
|
||||
template <bool>
|
||||
struct CompileAssert {
|
||||
};
|
||||
|
||||
#define COMPILE_ASSERT(expr, msg) \
|
||||
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
|
||||
|
||||
#endif // __cplusplus >= 201103L
|
||||
#endif // !defined(COMPILE_ASSERT)
|
||||
|
||||
// Implementation details of COMPILE_ASSERT:
|
||||
//
|
||||
// - COMPILE_ASSERT works by defining an array type that has -1
|
||||
// elements (and thus is invalid) when the expression is false.
|
||||
//
|
||||
// - The simpler definition
|
||||
//
|
||||
// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
|
||||
//
|
||||
// does not work, as gcc supports variable-length arrays whose sizes
|
||||
// are determined at run-time (this is gcc's extension and not part
|
||||
// of the C++ standard). As a result, gcc fails to reject the
|
||||
// following code with the simple definition:
|
||||
//
|
||||
// int foo;
|
||||
// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
|
||||
// // not a compile-time constant.
|
||||
//
|
||||
// - By using the type CompileAssert<(bool(expr))>, we ensures that
|
||||
// expr is a compile-time constant. (Template arguments must be
|
||||
// determined at compile-time.)
|
||||
//
|
||||
// - The outer parentheses in CompileAssert<(bool(expr))> are necessary
|
||||
// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
|
||||
//
|
||||
// CompileAssert<bool(expr)>
|
||||
//
|
||||
// instead, these compilers will refuse to compile
|
||||
//
|
||||
// COMPILE_ASSERT(5 > 0, some_message);
|
||||
//
|
||||
// (They seem to think the ">" in "5 > 0" marks the end of the
|
||||
// template argument list.)
|
||||
//
|
||||
// - The array size is (bool(expr) ? 1 : -1), instead of simply
|
||||
//
|
||||
// ((expr) ? 1 : -1).
|
||||
//
|
||||
// This is to avoid running into a bug in MS VC 7.1, which
|
||||
// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
|
||||
|
||||
#endif // WEBRTC_BASE_COMPILE_ASSERT_H_
|
@ -15,8 +15,6 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
|
||||
namespace rtc {
|
||||
namespace internal {
|
||||
|
||||
@ -177,10 +175,10 @@ struct RangeCheckImpl<Dst, Src, DST_UNSIGNED, SRC_SIGNED, OVERLAPS_RANGE> {
|
||||
|
||||
template <typename Dst, typename Src>
|
||||
inline RangeCheckResult RangeCheck(Src value) {
|
||||
COMPILE_ASSERT(std::numeric_limits<Src>::is_specialized,
|
||||
argument_must_be_numeric);
|
||||
COMPILE_ASSERT(std::numeric_limits<Dst>::is_specialized,
|
||||
result_must_be_numeric);
|
||||
static_assert(std::numeric_limits<Src>::is_specialized,
|
||||
"argument must be numeric");
|
||||
static_assert(std::numeric_limits<Dst>::is_specialized,
|
||||
"result must be numeric");
|
||||
return RangeCheckImpl<Dst, Src>::Check(value);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,6 @@
|
||||
#include <algorithm> // For std::swap().
|
||||
|
||||
#include "webrtc/base/common.h" // for ASSERT
|
||||
#include "webrtc/base/compile_assert.h" // for COMPILE_ASSERT
|
||||
#include "webrtc/base/move.h" // for RTC_MOVE_ONLY_TYPE_FOR_CPP_03
|
||||
#include "webrtc/base/template_util.h" // for is_convertible, is_array
|
||||
|
||||
@ -121,7 +120,7 @@ struct DefaultDeleter {
|
||||
//
|
||||
// Correct implementation should use SFINAE to disable this
|
||||
// constructor. However, since there are no other 1-argument constructors,
|
||||
// using a COMPILE_ASSERT() based on is_convertible<> and requiring
|
||||
// using a static_assert based on is_convertible<> and requiring
|
||||
// complete types is simpler and will cause compile failures for equivalent
|
||||
// misuses.
|
||||
//
|
||||
@ -130,8 +129,8 @@ struct DefaultDeleter {
|
||||
// cannot convert to T*.
|
||||
enum { T_must_be_complete = sizeof(T) };
|
||||
enum { U_must_be_complete = sizeof(U) };
|
||||
COMPILE_ASSERT((rtc::is_convertible<U*, T*>::value),
|
||||
U_ptr_must_implicitly_convert_to_T_ptr);
|
||||
static_assert(rtc::is_convertible<U*, T*>::value,
|
||||
"U* must implicitly convert to T*");
|
||||
}
|
||||
inline void operator()(T* ptr) const {
|
||||
enum { type_must_be_complete = sizeof(T) };
|
||||
@ -161,7 +160,7 @@ struct DefaultDeleter<T[]> {
|
||||
template <class T, int n>
|
||||
struct DefaultDeleter<T[n]> {
|
||||
// Never allow someone to declare something like scoped_ptr<int[10]>.
|
||||
COMPILE_ASSERT(sizeof(T) == -1, do_not_use_array_with_size_as_type);
|
||||
static_assert(sizeof(T) == -1, "do not use array with size as type");
|
||||
};
|
||||
|
||||
// Function object which invokes 'free' on its parameter, which must be
|
||||
@ -337,7 +336,7 @@ class scoped_ptr {
|
||||
// implementation of scoped_ptr.
|
||||
template <typename U, typename V>
|
||||
scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
|
||||
COMPILE_ASSERT(!rtc::is_array<U>::value, U_cannot_be_an_array);
|
||||
static_assert(!rtc::is_array<U>::value, "U cannot be an array");
|
||||
}
|
||||
|
||||
// Constructor. Move constructor for C++03 move emulation of this type.
|
||||
@ -355,7 +354,7 @@ class scoped_ptr {
|
||||
// scoped_ptr.
|
||||
template <typename U, typename V>
|
||||
scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
|
||||
COMPILE_ASSERT(!rtc::is_array<U>::value, U_cannot_be_an_array);
|
||||
static_assert(!rtc::is_array<U>::value, "U cannot be an array");
|
||||
impl_.TakeState(&rhs.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
@ -85,7 +85,6 @@
|
||||
// MSVC++ requires this to be set before any other includes to get M_PI.
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/common_audio/resampler/sinc_resampler.h"
|
||||
#include "webrtc/system_wrappers/interface/cpu_features_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <limits>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/common_audio/wav_header.h"
|
||||
#include "webrtc/common_audio/wav_file.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
@ -67,7 +66,7 @@ TEST(WavWriterTest, CPP) {
|
||||
};
|
||||
static const int kContentSize =
|
||||
kWavHeaderSize + kNumSamples * sizeof(int16_t) + sizeof(kMetadata);
|
||||
COMPILE_ASSERT(sizeof(kExpectedContents) == kContentSize, content_size);
|
||||
static_assert(sizeof(kExpectedContents) == kContentSize, "content size");
|
||||
EXPECT_EQ(size_t(kContentSize), test::GetFileSize(outfile));
|
||||
FILE* f = fopen(outfile.c_str(), "rb");
|
||||
ASSERT_TRUE(f);
|
||||
@ -123,7 +122,7 @@ TEST(WavWriterTest, C) {
|
||||
};
|
||||
static const int kContentSize =
|
||||
kWavHeaderSize + kNumSamples * sizeof(int16_t);
|
||||
COMPILE_ASSERT(sizeof(kExpectedContents) == kContentSize, content_size);
|
||||
static_assert(sizeof(kExpectedContents) == kContentSize, "content size");
|
||||
EXPECT_EQ(size_t(kContentSize), test::GetFileSize(outfile));
|
||||
FILE* f = fopen(outfile.c_str(), "rb");
|
||||
ASSERT_TRUE(f);
|
||||
|
@ -29,7 +29,7 @@ struct ChunkHeader {
|
||||
uint32_t ID;
|
||||
uint32_t Size;
|
||||
};
|
||||
COMPILE_ASSERT(sizeof(ChunkHeader) == 8, chunk_header_size);
|
||||
static_assert(sizeof(ChunkHeader) == 8, "ChunkHeader size");
|
||||
|
||||
// We can't nest this definition in WavHeader, because VS2013 gives an error
|
||||
// on sizeof(WavHeader::fmt): "error C2070: 'unknown': illegal sizeof operand".
|
||||
@ -42,7 +42,7 @@ struct FmtSubchunk {
|
||||
uint16_t BlockAlign;
|
||||
uint16_t BitsPerSample;
|
||||
};
|
||||
COMPILE_ASSERT(sizeof(FmtSubchunk) == 24, fmt_subchunk_size);
|
||||
static_assert(sizeof(FmtSubchunk) == 24, "FmtSubchunk size");
|
||||
const uint32_t kFmtSubchunkSize = sizeof(FmtSubchunk) - sizeof(ChunkHeader);
|
||||
|
||||
struct WavHeader {
|
||||
@ -55,7 +55,7 @@ struct WavHeader {
|
||||
ChunkHeader header;
|
||||
} data;
|
||||
};
|
||||
COMPILE_ASSERT(sizeof(WavHeader) == kWavHeaderSize, no_padding_in_header);
|
||||
static_assert(sizeof(WavHeader) == kWavHeaderSize, "no padding in header");
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <limits>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/common_audio/wav_header.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -266,7 +265,7 @@ TEST(WavHeaderTest, WriteAndReadWavHeader) {
|
||||
0x99, 0xd0, 0x5b, 0x07, // size of payload: 123457689
|
||||
0xa4, 0xa4, 0xa4, 0xa4, // untouched bytes after header
|
||||
};
|
||||
COMPILE_ASSERT(sizeof(kExpectedBuf) == kSize, buf_size);
|
||||
static_assert(sizeof(kExpectedBuf) == kSize, "buffer size");
|
||||
EXPECT_EQ(0, memcmp(kExpectedBuf, buf, kSize));
|
||||
|
||||
int num_channels = 0;
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/base/md5digest.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/audio_coding/main/acm2/acm_receive_test.h"
|
||||
@ -133,8 +132,8 @@ class AudioCodingModuleTest : public ::testing::Test {
|
||||
input_frame_.sample_rate_hz_ = kSampleRateHz;
|
||||
input_frame_.num_channels_ = 1;
|
||||
input_frame_.samples_per_channel_ = kSampleRateHz * 10 / 1000; // 10 ms.
|
||||
COMPILE_ASSERT(kSampleRateHz * 10 / 1000 <= AudioFrame::kMaxDataSizeSamples,
|
||||
audio_frame_too_small);
|
||||
static_assert(kSampleRateHz * 10 / 1000 <= AudioFrame::kMaxDataSizeSamples,
|
||||
"audio frame too small");
|
||||
memset(input_frame_.data_,
|
||||
0,
|
||||
input_frame_.samples_per_channel_ * sizeof(input_frame_.data_[0]));
|
||||
@ -461,7 +460,7 @@ class AcmIsacMtTest : public AudioCodingModuleMtTest {
|
||||
}
|
||||
|
||||
virtual void RegisterCodec() OVERRIDE {
|
||||
COMPILE_ASSERT(kSampleRateHz == 16000, test_designed_for_isac_16khz);
|
||||
static_assert(kSampleRateHz == 16000, "test designed for iSAC 16 kHz");
|
||||
|
||||
// Register iSAC codec in ACM, effectively unregistering the PCM16B codec
|
||||
// registered in AudioCodingModuleTest::SetUp();
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/base/md5digest.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h"
|
||||
@ -137,8 +136,8 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
||||
input_frame_.sample_rate_hz_ = kSampleRateHz;
|
||||
input_frame_.num_channels_ = 1;
|
||||
input_frame_.samples_per_channel_ = kSampleRateHz * 10 / 1000; // 10 ms.
|
||||
COMPILE_ASSERT(kSampleRateHz * 10 / 1000 <= AudioFrame::kMaxDataSizeSamples,
|
||||
audio_frame_too_small);
|
||||
static_assert(kSampleRateHz * 10 / 1000 <= AudioFrame::kMaxDataSizeSamples,
|
||||
"audio frame too small");
|
||||
memset(input_frame_.data_,
|
||||
0,
|
||||
input_frame_.samples_per_channel_ * sizeof(input_frame_.data_[0]));
|
||||
@ -463,7 +462,7 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi {
|
||||
}
|
||||
|
||||
virtual void RegisterCodec() {
|
||||
COMPILE_ASSERT(kSampleRateHz == 16000, test_designed_for_isac_16khz);
|
||||
static_assert(kSampleRateHz == 16000, "test designed for iSAC 16 kHz");
|
||||
AudioCodingModule::Codec("ISAC", &codec_, kSampleRateHz, 1);
|
||||
codec_.pltype = kPayloadType;
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/interface/neteq.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
|
||||
@ -360,11 +359,11 @@ TEST_F(LargeTimestampJumpTest, JumpLongerThanHalfRange) {
|
||||
static const uint32_t kStartTimestamp = 2880;
|
||||
static const uint32_t kJumpFromTimestamp = 7200;
|
||||
static const uint32_t kJumpToTimestamp = 2869342376;
|
||||
COMPILE_ASSERT(kJumpFromTimestamp < kJumpToTimestamp,
|
||||
timestamp_jump_should_not_result_in_wrap);
|
||||
COMPILE_ASSERT(
|
||||
static_assert(kJumpFromTimestamp < kJumpToTimestamp,
|
||||
"timestamp jump should not result in wrap");
|
||||
static_assert(
|
||||
static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) > 0x7FFFFFFF,
|
||||
jump_should_be_larger_than_half_range);
|
||||
"jump should be larger than half range");
|
||||
// Replace the default RTP generator with one that jumps in timestamp.
|
||||
rtp_generator_.reset(new test::TimestampJumpRtpGenerator(samples_per_ms_,
|
||||
kStartSeqeunceNumber,
|
||||
@ -384,11 +383,11 @@ TEST_F(LargeTimestampJumpTest, JumpLongerThanHalfRangeAndWrap) {
|
||||
static const uint32_t kStartTimestamp = 3221223116;
|
||||
static const uint32_t kJumpFromTimestamp = 3221223216;
|
||||
static const uint32_t kJumpToTimestamp = 1073744278;
|
||||
COMPILE_ASSERT(kJumpToTimestamp < kJumpFromTimestamp,
|
||||
timestamp_jump_should_result_in_wrap);
|
||||
COMPILE_ASSERT(
|
||||
static_assert(kJumpToTimestamp < kJumpFromTimestamp,
|
||||
"timestamp jump should result in wrap");
|
||||
static_assert(
|
||||
static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) > 0x7FFFFFFF,
|
||||
jump_should_be_larger_than_half_range);
|
||||
"jump should be larger than half range");
|
||||
// Replace the default RTP generator with one that jumps in timestamp.
|
||||
rtp_generator_.reset(new test::TimestampJumpRtpGenerator(samples_per_ms_,
|
||||
kStartSeqeunceNumber,
|
||||
@ -443,11 +442,11 @@ TEST_F(ShortTimestampJumpTest, JumpShorterThanHalfRange) {
|
||||
static const uint32_t kStartTimestamp = 4711;
|
||||
static const uint32_t kJumpFromTimestamp = 4811;
|
||||
static const uint32_t kJumpToTimestamp = 2147483747;
|
||||
COMPILE_ASSERT(kJumpFromTimestamp < kJumpToTimestamp,
|
||||
timestamp_jump_should_not_result_in_wrap);
|
||||
COMPILE_ASSERT(
|
||||
static_assert(kJumpFromTimestamp < kJumpToTimestamp,
|
||||
"timestamp jump should not result in wrap");
|
||||
static_assert(
|
||||
static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF,
|
||||
jump_should_be_smaller_than_half_range);
|
||||
"jump should be smaller than half range");
|
||||
// Replace the default RTP generator with one that jumps in timestamp.
|
||||
rtp_generator_.reset(new test::TimestampJumpRtpGenerator(samples_per_ms_,
|
||||
kStartSeqeunceNumber,
|
||||
@ -467,11 +466,11 @@ TEST_F(ShortTimestampJumpTest, JumpShorterThanHalfRangeAndWrap) {
|
||||
static const uint32_t kStartTimestamp = 3221227827;
|
||||
static const uint32_t kJumpFromTimestamp = 3221227927;
|
||||
static const uint32_t kJumpToTimestamp = 1073739567;
|
||||
COMPILE_ASSERT(kJumpToTimestamp < kJumpFromTimestamp,
|
||||
timestamp_jump_should_result_in_wrap);
|
||||
COMPILE_ASSERT(
|
||||
static_assert(kJumpToTimestamp < kJumpFromTimestamp,
|
||||
"timestamp jump should result in wrap");
|
||||
static_assert(
|
||||
static_cast<uint32_t>(kJumpToTimestamp - kJumpFromTimestamp) < 0x7FFFFFFF,
|
||||
jump_should_be_smaller_than_half_range);
|
||||
"jump should be smaller than half range");
|
||||
// Replace the default RTP generator with one that jumps in timestamp.
|
||||
rtp_generator_.reset(new test::TimestampJumpRtpGenerator(samples_per_ms_,
|
||||
kStartSeqeunceNumber,
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/md5digest.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/common_audio/resampler/include/resampler.h"
|
||||
#include "webrtc/modules/audio_processing/agc/agc_audio_proc.h"
|
||||
#include "webrtc/modules/audio_processing/agc/common.h"
|
||||
@ -99,8 +98,8 @@ int Agc::Process(const int16_t* audio, int length, int sample_rate_hz) {
|
||||
// Initialize to 0.5 which is a neutral value for combining probabilities,
|
||||
// in case the standalone-VAD is not enabled.
|
||||
double p_combined[] = {0.5, 0.5, 0.5, 0.5};
|
||||
COMPILE_ASSERT(sizeof(p_combined) / sizeof(p_combined[0]) == kMaxNumFrames,
|
||||
combined_probability_incorrect_size);
|
||||
static_assert(sizeof(p_combined) / sizeof(p_combined[0]) == kMaxNumFrames,
|
||||
"combined probability incorrect size");
|
||||
if (standalone_vad_enabled_) {
|
||||
if (standalone_vad_->GetActivity(p_combined, kMaxNumFrames) < 0)
|
||||
return -1;
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/audio_processing/agc/agc_audio_proc_internal.h"
|
||||
#include "webrtc/modules/audio_processing/agc/pitch_internal.h"
|
||||
#include "webrtc/modules/audio_processing/agc/pole_zero_filter.h"
|
||||
@ -47,11 +46,11 @@ AgcAudioProc::AgcAudioProc()
|
||||
pre_filter_handle_(new PreFiltBankstr),
|
||||
high_pass_filter_(PoleZeroFilter::Create(
|
||||
kCoeffNumerator, kFilterOrder, kCoeffDenominator, kFilterOrder)) {
|
||||
COMPILE_ASSERT(kNumPastSignalSamples + kNumSubframeSamples ==
|
||||
sizeof(kLpcAnalWin) / sizeof(kLpcAnalWin[0]),
|
||||
lpc_analysis_window_incorrect_size);
|
||||
COMPILE_ASSERT(kLpcOrder + 1 == sizeof(kCorrWeight) / sizeof(kCorrWeight[0]),
|
||||
correlation_weight_incorrect_size);
|
||||
static_assert(kNumPastSignalSamples + kNumSubframeSamples ==
|
||||
sizeof(kLpcAnalWin) / sizeof(kLpcAnalWin[0]),
|
||||
"lpc analysis window incorrect size");
|
||||
static_assert(kLpcOrder + 1 == sizeof(kCorrWeight) / sizeof(kCorrWeight[0]),
|
||||
"correlation weight incorrect size");
|
||||
|
||||
// TODO(turajs): Are we doing too much in the constructor?
|
||||
float data[kDftSize];
|
||||
|
@ -11,8 +11,6 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_AUDIO_PROC_INTERNAL_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_AUDIO_PROC_INTERNAL_H_
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// These values should match MATLAB counterparts for unit-tests to pass.
|
||||
@ -71,10 +69,12 @@ static const float kCoeffNumerator[kFilterOrder + 1] = {0.974827f, -1.949650f,
|
||||
static const float kCoeffDenominator[kFilterOrder + 1] = {1.0f, -1.971999f,
|
||||
0.972457f};
|
||||
|
||||
COMPILE_ASSERT(kFilterOrder + 1 == sizeof(kCoeffNumerator) /
|
||||
sizeof(kCoeffNumerator[0]), numerator_coefficients_incorrect_size);
|
||||
COMPILE_ASSERT(kFilterOrder + 1 == sizeof(kCoeffDenominator) /
|
||||
sizeof(kCoeffDenominator[0]), denominator_coefficients_incorrect_size);
|
||||
static_assert(kFilterOrder + 1 ==
|
||||
sizeof(kCoeffNumerator) / sizeof(kCoeffNumerator[0]),
|
||||
"numerator coefficients incorrect size");
|
||||
static_assert(kFilterOrder + 1 ==
|
||||
sizeof(kCoeffDenominator) / sizeof(kCoeffDenominator[0]),
|
||||
"denominator coefficients incorrect size");
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/audio_processing/agc/gain_map_internal.h"
|
||||
#include "webrtc/modules/audio_processing/gain_control_impl.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
@ -47,7 +46,7 @@ const int kMinCompressionGain = 2;
|
||||
const float kCompressionGainStep = 0.05f;
|
||||
|
||||
const int kMaxMicLevel = 255;
|
||||
COMPILE_ASSERT(kGainMapSize > kMaxMicLevel, gain_map_too_small);
|
||||
static_assert(kGainMapSize > kMaxMicLevel, "gain map too small");
|
||||
const int kMinMicLevel = 12;
|
||||
const int kMinInitMicLevel = 85;
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -69,8 +68,9 @@ Histogram::Histogram()
|
||||
buffer_is_full_(false),
|
||||
len_circular_buffer_(0),
|
||||
len_high_activity_(0) {
|
||||
COMPILE_ASSERT(kHistSize == sizeof(kHistBinCenters) /
|
||||
sizeof(kHistBinCenters[0]), histogram_bin_centers_incorrect_size);
|
||||
static_assert(
|
||||
kHistSize == sizeof(kHistBinCenters) / sizeof(kHistBinCenters[0]),
|
||||
"histogram bin centers incorrect size");
|
||||
}
|
||||
|
||||
Histogram::Histogram(int window_size)
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/audio_processing/agc/circular_buffer.h"
|
||||
#include "webrtc/modules/audio_processing/agc/common.h"
|
||||
#include "webrtc/modules/audio_processing/agc/noise_gmm_tables.h"
|
||||
@ -23,8 +22,8 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
COMPILE_ASSERT(kNoiseGmmDim == kVoiceGmmDim,
|
||||
noise_and_voice_gmm_dimension_not_equal);
|
||||
static_assert(kNoiseGmmDim == kVoiceGmmDim,
|
||||
"noise and voice gmm dimension not equal");
|
||||
|
||||
// These values should match MATLAB counterparts for unit-tests to pass.
|
||||
static const int kPosteriorHistorySize = 500; // 5 sec of 10 ms frames.
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/audio_processing/agc/agc_audio_proc_internal.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/base/platform_file.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
@ -55,7 +54,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
// Throughout webrtc, it's assumed that success is represented by zero.
|
||||
COMPILE_ASSERT(AudioProcessing::kNoError == 0, no_error_must_be_zero);
|
||||
static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero");
|
||||
|
||||
// This class has two main functionalities:
|
||||
//
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/file_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -24,8 +23,8 @@ namespace webrtc {
|
||||
template <class Dest, class Source>
|
||||
inline Dest bit_cast(const Source& source) {
|
||||
// A compile error here means your Dest and Source have different sizes.
|
||||
COMPILE_ASSERT(sizeof(Dest) == sizeof(Source),
|
||||
dest_and_source_have_different_sizes);
|
||||
static_assert(sizeof(Dest) == sizeof(Source),
|
||||
"Dest and Source have different sizes");
|
||||
|
||||
Dest dest;
|
||||
memcpy(&dest, &source, sizeof(dest));
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/desktop_capture/win/scoped_gdi_object.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
|
||||
@ -78,8 +77,8 @@ void AddCursorOutline(int width, int height, uint32_t* data) {
|
||||
// Premultiplies RGB components of the pixel data in the given image by
|
||||
// the corresponding alpha components.
|
||||
void AlphaMul(uint32_t* data, int width, int height) {
|
||||
COMPILE_ASSERT(sizeof(uint32_t) == kBytesPerPixel,
|
||||
size_of_uint32_should_be_the_bytes_per_pixel);
|
||||
static_assert(sizeof(uint32_t) == kBytesPerPixel,
|
||||
"size of uint32 should be the number of bytes per pixel");
|
||||
|
||||
for (uint32_t* data_end = data + width * height; data != data_end; ++data) {
|
||||
RGBQUAD* from = reinterpret_cast<RGBQUAD*>(data);
|
||||
|
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/media_file/interface/media_file.h"
|
||||
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
@ -78,7 +77,7 @@ TEST_F(MediaFileTest, WriteWavFile) {
|
||||
'd', 'a', 't', 'a',
|
||||
0x40, 0x1, 0, 0, // size of payload: 320
|
||||
};
|
||||
COMPILE_ASSERT(sizeof(kExpectedHeader) == kHeaderSize, header_size);
|
||||
static_assert(sizeof(kExpectedHeader) == kHeaderSize, "header size");
|
||||
|
||||
EXPECT_EQ(kHeaderSize + kPayloadSize, webrtc::test::GetFileSize(outfile));
|
||||
FILE* f = fopen(outfile.c_str(), "rb");
|
||||
|
@ -14,14 +14,13 @@
|
||||
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#define CHECK_ARRAY_SIZE(expected_size, array) \
|
||||
COMPILE_ASSERT(expected_size == sizeof(array) / sizeof(array[0]), \
|
||||
check_array_size);
|
||||
#define CHECK_ARRAY_SIZE(expected_size, array) \
|
||||
static_assert(expected_size == sizeof(array) / sizeof(array[0]), \
|
||||
"check array size");
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
@ -40,8 +40,8 @@ void (*g_logging_delegate_function)(const std::string&) = NULL;
|
||||
void (*g_extra_logging_init_function)(
|
||||
void (*logging_delegate_function)(const std::string&)) = NULL;
|
||||
#ifndef NDEBUG
|
||||
COMPILE_ASSERT(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId),
|
||||
atomic32_not_same_size_as_platformthreadid);
|
||||
static_assert(sizeof(base::subtle::Atomic32) == sizeof(base::PlatformThreadId),
|
||||
"Atomic32 not same size as PlatformThreadId");
|
||||
base::subtle::Atomic32 g_init_logging_delegate_thread_id = 0;
|
||||
#endif
|
||||
|
||||
|
@ -11,8 +11,10 @@
|
||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_
|
||||
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_
|
||||
|
||||
// Only use this for C files. For C++, use compile_assert.h.
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#error "Only use this for C files. For C++, use static_assert."
|
||||
#endif
|
||||
|
||||
// Use this macro to verify at compile time that certain restrictions are met.
|
||||
// The argument is the boolean expression to evaluate.
|
||||
// Example:
|
||||
|
@ -104,7 +104,6 @@
|
||||
|
||||
#include <algorithm> // For std::swap().
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/move.h"
|
||||
#include "webrtc/base/template_util.h"
|
||||
@ -124,7 +123,7 @@ struct DefaultDeleter {
|
||||
//
|
||||
// Correct implementation should use SFINAE to disable this
|
||||
// constructor. However, since there are no other 1-argument constructors,
|
||||
// using a COMPILE_ASSERT() based on is_convertible<> and requiring
|
||||
// using a static_assert based on is_convertible<> and requiring
|
||||
// complete types is simpler and will cause compile failures for equivalent
|
||||
// misuses.
|
||||
//
|
||||
@ -133,8 +132,8 @@ struct DefaultDeleter {
|
||||
// cannot convert to T*.
|
||||
enum { T_must_be_complete = sizeof(T) };
|
||||
enum { U_must_be_complete = sizeof(U) };
|
||||
COMPILE_ASSERT((rtc::is_convertible<U*, T*>::value),
|
||||
U_ptr_must_implicitly_convert_to_T_ptr);
|
||||
static_assert(rtc::is_convertible<U*, T*>::value,
|
||||
"U* must implicitly convert to T*");
|
||||
}
|
||||
inline void operator()(T* ptr) const {
|
||||
enum { type_must_be_complete = sizeof(T) };
|
||||
@ -164,7 +163,7 @@ struct DefaultDeleter<T[]> {
|
||||
template <class T, int n>
|
||||
struct DefaultDeleter<T[n]> {
|
||||
// Never allow someone to declare something like scoped_ptr<int[10]>.
|
||||
COMPILE_ASSERT(sizeof(T) == -1, do_not_use_array_with_size_as_type);
|
||||
static_assert(sizeof(T) == -1, "do not use array with size as type");
|
||||
};
|
||||
|
||||
// Function object which invokes 'free' on its parameter, which must be
|
||||
@ -318,8 +317,8 @@ class scoped_ptr {
|
||||
|
||||
// TODO(ajm): If we ever import RefCountedBase, this check needs to be
|
||||
// enabled.
|
||||
//COMPILE_ASSERT(webrtc::internal::IsNotRefCounted<T>::value,
|
||||
// T_is_refcounted_type_and_needs_scoped_refptr);
|
||||
//static_assert(webrtc::internal::IsNotRefCounted<T>::value,
|
||||
// "T is refcounted type and needs scoped refptr");
|
||||
|
||||
public:
|
||||
// The element and deleter types.
|
||||
@ -351,7 +350,7 @@ class scoped_ptr {
|
||||
template <typename U, typename V>
|
||||
scoped_ptr(scoped_ptr<U, V>&& other)
|
||||
: impl_(&other.impl_) {
|
||||
COMPILE_ASSERT(!rtc::is_array<U>::value, U_cannot_be_an_array);
|
||||
static_assert(!rtc::is_array<U>::value, "U cannot be an array");
|
||||
}
|
||||
|
||||
// operator=. Allows assignment from a scoped_ptr rvalue for a convertible
|
||||
@ -366,7 +365,7 @@ class scoped_ptr {
|
||||
// scoped_ptr.
|
||||
template <typename U, typename V>
|
||||
scoped_ptr& operator=(scoped_ptr<U, V>&& rhs) {
|
||||
COMPILE_ASSERT(!rtc::is_array<U>::value, U_cannot_be_an_array);
|
||||
static_assert(!rtc::is_array<U>::value, "U cannot be an array");
|
||||
impl_.TakeState(&rhs.impl_);
|
||||
return *this;
|
||||
}
|
||||
|
@ -13,15 +13,14 @@
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
Atomic32::Atomic32(int32_t initial_value)
|
||||
: value_(initial_value) {
|
||||
COMPILE_ASSERT(sizeof(value_) == sizeof(LONG),
|
||||
counter_variable_is_the_expected_size);
|
||||
static_assert(sizeof(value_) == sizeof(LONG),
|
||||
"counter variable is the expected size");
|
||||
assert(Is32bitAligned());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user