Unify the two copies of compile_assert.h
This patch basically deletes webrtc/base/compile_assert.h (which is the more outdated copy) and moves webrtc/system_wrappers/source/compile_assert.h to take its place. R=aluebs@webrtc.org, andrew@webrtc.org, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/36719004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8048 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
58a1ba6ffc
commit
3df38b442f
@ -78,12 +78,12 @@
|
||||
#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"
|
||||
#include "webrtc/common_video/interface/texture_video_frame.h"
|
||||
#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
#include "webrtc/video_engine/include/vie_base.h"
|
||||
#include "webrtc/voice_engine/include/voe_base.h"
|
||||
|
@ -106,6 +106,7 @@ static_library("rtc_base_approved") {
|
||||
sources = [
|
||||
"checks.cc",
|
||||
"checks.h",
|
||||
"compile_assert.h",
|
||||
"exp_filter.cc",
|
||||
"exp_filter.h",
|
||||
"md5.cc",
|
||||
|
@ -41,6 +41,7 @@
|
||||
'sources': [
|
||||
'checks.cc',
|
||||
'checks.h',
|
||||
'compile_assert.h',
|
||||
'exp_filter.cc',
|
||||
'exp_filter.h',
|
||||
'md5.cc',
|
||||
|
@ -8,16 +8,16 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// COMPILE_ASSERT macro, borrowed from google3/base/macros.h.
|
||||
// Borrowed from Chromium's src/base/macros.h.
|
||||
|
||||
#ifndef WEBRTC_BASE_COMPILE_ASSERT_H_
|
||||
#define WEBRTC_BASE_COMPILE_ASSERT_H_
|
||||
#include "webrtc/typedefs.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(content_type_names) == CONTENT_NUM_TYPES,
|
||||
// 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:
|
||||
@ -31,13 +31,20 @@
|
||||
// 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] ATTRIBUTE_UNUSED
|
||||
#endif // COMPILE_ASSERT
|
||||
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
|
||||
|
||||
#endif // __cplusplus >= 201103L
|
||||
#endif // !defined(COMPILE_ASSERT)
|
||||
|
||||
// Implementation details of COMPILE_ASSERT:
|
||||
//
|
||||
|
@ -85,8 +85,8 @@
|
||||
// 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/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/cpu_features_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include <limits>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/common_audio/wav_header.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#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"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
#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"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
#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"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/test/testsupport/gtest_disable.h"
|
||||
|
@ -13,11 +13,11 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/md5digest.h"
|
||||
#include "webrtc/base/stringencode.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#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"
|
||||
@ -23,7 +24,6 @@
|
||||
#include "webrtc/modules/audio_processing/agc/standalone_vad.h"
|
||||
#include "webrtc/modules/audio_processing/agc/utility.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#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"
|
||||
@ -24,7 +25,6 @@ extern "C" {
|
||||
#include "webrtc/modules/audio_processing/utility/fft4g.h"
|
||||
}
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_AUDIO_PROC_INTERNAL_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_AUDIO_PROC_INTERNAL_H_
|
||||
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -17,10 +17,10 @@
|
||||
#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"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -14,12 +14,12 @@
|
||||
#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"
|
||||
#include "webrtc/modules/audio_processing/agc/voice_gmm_tables.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
#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/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#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"
|
||||
@ -30,7 +31,6 @@
|
||||
#include "webrtc/modules/audio_processing/transient/transient_suppressor.h"
|
||||
#include "webrtc/modules/audio_processing/voice_detection_impl.h"
|
||||
#include "webrtc/modules/interface/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/file_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
|
@ -12,11 +12,11 @@
|
||||
|
||||
#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"
|
||||
#include "webrtc/modules/desktop_capture/mouse_cursor.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/logging.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
@ -9,8 +9,8 @@
|
||||
*/
|
||||
|
||||
#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/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/test/testsupport/gtest_disable.h"
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
#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/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#define CHECK_ARRAY_SIZE(expected_size, array) \
|
||||
|
@ -21,7 +21,6 @@ static_library("system_wrappers") {
|
||||
"interface/aligned_malloc.h",
|
||||
"interface/atomic32.h",
|
||||
"interface/clock.h",
|
||||
"interface/compile_assert.h",
|
||||
"interface/condition_variable_wrapper.h",
|
||||
"interface/cpu_info.h",
|
||||
"interface/cpu_features_wrapper.h",
|
||||
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_
|
||||
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_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_SYSTEM_WRAPPERS_INTERFACE_COMPILE_ASSERT_H_
|
@ -104,9 +104,9 @@
|
||||
|
||||
#include <algorithm> // For std::swap().
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/move.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
#include "webrtc/system_wrappers/interface/template_util.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "webrtc/base/compile_assert.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/system_wrappers/interface/compile_assert.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
@ -29,7 +29,6 @@
|
||||
'../interface/aligned_malloc.h',
|
||||
'../interface/atomic32.h',
|
||||
'../interface/clock.h',
|
||||
'../interface/compile_assert.h',
|
||||
'../interface/condition_variable_wrapper.h',
|
||||
'../interface/cpu_info.h',
|
||||
'../interface/cpu_features_wrapper.h',
|
||||
|
Loading…
Reference in New Issue
Block a user