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:
kwiberg@webrtc.org
2015-01-14 10:51:54 +00:00
parent 86e1e487e7
commit 2ebfac5649
30 changed files with 85 additions and 198 deletions

View File

@ -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;

View File

@ -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];

View File

@ -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

View File

@ -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;

View File

@ -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)

View File

@ -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.

View File

@ -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"

View File

@ -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:
//

View File

@ -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));