Skip to content

Commit 1999d20

Browse files
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. [email protected], [email protected], [email protected] Review URL: https://webrtc-codereview.appspot.com/36719004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8048 4adac7df-926f-26a2-2b94-8c16560cd09d
1 parent 021ef7e commit 1999d20

26 files changed

+34
-117
lines changed

talk/app/webrtc/java/jni/peerconnection_jni.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@
7878
#include "third_party/libyuv/include/libyuv/video_common.h"
7979
#include "webrtc/base/bind.h"
8080
#include "webrtc/base/checks.h"
81+
#include "webrtc/base/compile_assert.h"
8182
#include "webrtc/base/logging.h"
8283
#include "webrtc/base/messagequeue.h"
8384
#include "webrtc/base/ssladapter.h"
8485
#include "webrtc/common_video/interface/texture_video_frame.h"
8586
#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
86-
#include "webrtc/system_wrappers/interface/compile_assert.h"
8787
#include "webrtc/system_wrappers/interface/trace.h"
8888
#include "webrtc/video_engine/include/vie_base.h"
8989
#include "webrtc/voice_engine/include/voe_base.h"

webrtc/base/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static_library("rtc_base_approved") {
106106
sources = [
107107
"checks.cc",
108108
"checks.h",
109+
"compile_assert.h",
109110
"exp_filter.cc",
110111
"exp_filter.h",
111112
"md5.cc",

webrtc/base/base.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
'sources': [
4242
'checks.cc',
4343
'checks.h',
44+
'compile_assert.h',
4445
'exp_filter.cc',
4546
'exp_filter.h',
4647
'md5.cc',

webrtc/base/compile_assert.h

+12-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
* be found in the AUTHORS file in the root of the source tree.
99
*/
1010

11-
// COMPILE_ASSERT macro, borrowed from google3/base/macros.h.
11+
// Borrowed from Chromium's src/base/macros.h.
12+
1213
#ifndef WEBRTC_BASE_COMPILE_ASSERT_H_
1314
#define WEBRTC_BASE_COMPILE_ASSERT_H_
14-
#include "webrtc/typedefs.h"
1515

1616
// The COMPILE_ASSERT macro can be used to verify that a compile time
1717
// expression is true. For example, you could use it to verify the
1818
// size of a static array:
1919
//
20-
// COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,
20+
// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
2121
// content_type_names_incorrect_size);
2222
//
2323
// or to make sure a struct is smaller than a certain size:
@@ -31,13 +31,20 @@
3131
// TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and
3232
// libjingle are merged.
3333
#if !defined(COMPILE_ASSERT)
34+
#if __cplusplus >= 201103L
35+
// Under C++11, just use static_assert.
36+
#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
37+
38+
#else
3439
template <bool>
3540
struct CompileAssert {
3641
};
3742

3843
#define COMPILE_ASSERT(expr, msg) \
39-
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] ATTRIBUTE_UNUSED
40-
#endif // COMPILE_ASSERT
44+
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
45+
46+
#endif // __cplusplus >= 201103L
47+
#endif // !defined(COMPILE_ASSERT)
4148

4249
// Implementation details of COMPILE_ASSERT:
4350
//

webrtc/common_audio/resampler/sinc_resampler.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
// MSVC++ requires this to be set before any other includes to get M_PI.
8686
#define _USE_MATH_DEFINES
8787

88+
#include "webrtc/base/compile_assert.h"
8889
#include "webrtc/common_audio/resampler/sinc_resampler.h"
89-
#include "webrtc/system_wrappers/interface/compile_assert.h"
9090
#include "webrtc/system_wrappers/interface/cpu_features_wrapper.h"
9191
#include "webrtc/typedefs.h"
9292

webrtc/common_audio/wav_header_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <limits>
1212

1313
#include "testing/gtest/include/gtest/gtest.h"
14+
#include "webrtc/base/compile_assert.h"
1415
#include "webrtc/common_audio/wav_header.h"
15-
#include "webrtc/system_wrappers/interface/compile_assert.h"
1616

1717
namespace webrtc {
1818

webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "testing/gtest/include/gtest/gtest.h"
1515
#include "webrtc/base/checks.h"
16+
#include "webrtc/base/compile_assert.h"
1617
#include "webrtc/base/md5digest.h"
1718
#include "webrtc/base/thread_annotations.h"
1819
#include "webrtc/modules/audio_coding/main/acm2/acm_receive_test.h"
@@ -27,7 +28,6 @@
2728
#include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
2829
#include "webrtc/modules/interface/module_common_types.h"
2930
#include "webrtc/system_wrappers/interface/clock.h"
30-
#include "webrtc/system_wrappers/interface/compile_assert.h"
3131
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
3232
#include "webrtc/system_wrappers/interface/event_wrapper.h"
3333
#include "webrtc/system_wrappers/interface/scoped_ptr.h"

webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <vector>
1313

1414
#include "testing/gtest/include/gtest/gtest.h"
15+
#include "webrtc/base/compile_assert.h"
1516
#include "webrtc/base/md5digest.h"
1617
#include "webrtc/base/thread_annotations.h"
1718
#include "webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h"
@@ -27,7 +28,6 @@
2728
#include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
2829
#include "webrtc/modules/interface/module_common_types.h"
2930
#include "webrtc/system_wrappers/interface/clock.h"
30-
#include "webrtc/system_wrappers/interface/compile_assert.h"
3131
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
3232
#include "webrtc/system_wrappers/interface/event_wrapper.h"
3333
#include "webrtc/system_wrappers/interface/scoped_ptr.h"

webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
#include "testing/gmock/include/gmock/gmock.h"
1717
#include "testing/gtest/include/gtest/gtest.h"
18+
#include "webrtc/base/compile_assert.h"
1819
#include "webrtc/modules/audio_coding/neteq/interface/neteq.h"
1920
#include "webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h"
2021
#include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
2122
#include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h"
22-
#include "webrtc/system_wrappers/interface/compile_assert.h"
2323
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
2424
#include "webrtc/test/testsupport/fileutils.h"
2525
#include "webrtc/test/testsupport/gtest_disable.h"

webrtc/modules/audio_coding/neteq/tools/audio_checksum.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
#include <string>
1515

16+
#include "webrtc/base/compile_assert.h"
1617
#include "webrtc/base/constructormagic.h"
1718
#include "webrtc/base/md5digest.h"
1819
#include "webrtc/base/stringencode.h"
1920
#include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h"
20-
#include "webrtc/system_wrappers/interface/compile_assert.h"
2121
#include "webrtc/typedefs.h"
2222

2323
namespace webrtc {

webrtc/modules/audio_processing/agc/agc.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <algorithm>
1717

18+
#include "webrtc/base/compile_assert.h"
1819
#include "webrtc/common_audio/resampler/include/resampler.h"
1920
#include "webrtc/modules/audio_processing/agc/agc_audio_proc.h"
2021
#include "webrtc/modules/audio_processing/agc/common.h"
@@ -23,7 +24,6 @@
2324
#include "webrtc/modules/audio_processing/agc/standalone_vad.h"
2425
#include "webrtc/modules/audio_processing/agc/utility.h"
2526
#include "webrtc/modules/interface/module_common_types.h"
26-
#include "webrtc/system_wrappers/interface/compile_assert.h"
2727

2828
namespace webrtc {
2929
namespace {

webrtc/modules/audio_processing/agc/agc_audio_proc.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <math.h>
1414
#include <stdio.h>
1515

16+
#include "webrtc/base/compile_assert.h"
1617
#include "webrtc/modules/audio_processing/agc/agc_audio_proc_internal.h"
1718
#include "webrtc/modules/audio_processing/agc/pitch_internal.h"
1819
#include "webrtc/modules/audio_processing/agc/pole_zero_filter.h"
@@ -24,7 +25,6 @@ extern "C" {
2425
#include "webrtc/modules/audio_processing/utility/fft4g.h"
2526
}
2627
#include "webrtc/modules/interface/module_common_types.h"
27-
#include "webrtc/system_wrappers/interface/compile_assert.h"
2828

2929
namespace webrtc {
3030

webrtc/modules/audio_processing/agc/agc_audio_proc_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_AUDIO_PROC_INTERNAL_H_
1212
#define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_AUDIO_PROC_INTERNAL_H_
1313

14-
#include "webrtc/system_wrappers/interface/compile_assert.h"
14+
#include "webrtc/base/compile_assert.h"
1515

1616
namespace webrtc {
1717

webrtc/modules/audio_processing/agc/agc_manager_direct.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#include <cstdio>
1818
#endif
1919

20+
#include "webrtc/base/compile_assert.h"
2021
#include "webrtc/modules/audio_processing/agc/gain_map_internal.h"
2122
#include "webrtc/modules/audio_processing/gain_control_impl.h"
2223
#include "webrtc/modules/interface/module_common_types.h"
23-
#include "webrtc/system_wrappers/interface/compile_assert.h"
2424
#include "webrtc/system_wrappers/interface/logging.h"
2525

2626
namespace webrtc {

webrtc/modules/audio_processing/agc/histogram.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include <cmath>
1414
#include <cstring>
1515

16+
#include "webrtc/base/compile_assert.h"
1617
#include "webrtc/modules/interface/module_common_types.h"
17-
#include "webrtc/system_wrappers/interface/compile_assert.h"
1818

1919
namespace webrtc {
2020

webrtc/modules/audio_processing/agc/pitch_based_vad.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
#include <math.h>
1515
#include <string.h>
1616

17+
#include "webrtc/base/compile_assert.h"
1718
#include "webrtc/modules/audio_processing/agc/circular_buffer.h"
1819
#include "webrtc/modules/audio_processing/agc/common.h"
1920
#include "webrtc/modules/audio_processing/agc/noise_gmm_tables.h"
2021
#include "webrtc/modules/audio_processing/agc/voice_gmm_tables.h"
2122
#include "webrtc/modules/interface/module_common_types.h"
22-
#include "webrtc/system_wrappers/interface/compile_assert.h"
2323

2424
namespace webrtc {
2525

webrtc/modules/audio_processing/agc/pole_zero_filter_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <stdio.h>
1515

1616
#include "gtest/gtest.h"
17+
#include "webrtc/base/compile_assert.h"
1718
#include "webrtc/modules/audio_processing/agc/agc_audio_proc_internal.h"
18-
#include "webrtc/system_wrappers/interface/compile_assert.h"
1919
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
2020
#include "webrtc/test/testsupport/fileutils.h"
2121

webrtc/modules/audio_processing/audio_processing_impl.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <assert.h>
1414

15+
#include "webrtc/base/compile_assert.h"
1516
#include "webrtc/base/platform_file.h"
1617
#include "webrtc/common_audio/include/audio_util.h"
1718
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
@@ -30,7 +31,6 @@
3031
#include "webrtc/modules/audio_processing/transient/transient_suppressor.h"
3132
#include "webrtc/modules/audio_processing/voice_detection_impl.h"
3233
#include "webrtc/modules/interface/module_common_types.h"
33-
#include "webrtc/system_wrappers/interface/compile_assert.h"
3434
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
3535
#include "webrtc/system_wrappers/interface/file_wrapper.h"
3636
#include "webrtc/system_wrappers/interface/logging.h"

webrtc/modules/desktop_capture/win/cursor.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
#include <algorithm>
1414

15+
#include "webrtc/base/compile_assert.h"
1516
#include "webrtc/modules/desktop_capture/win/scoped_gdi_object.h"
1617
#include "webrtc/modules/desktop_capture/desktop_frame.h"
1718
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
1819
#include "webrtc/modules/desktop_capture/mouse_cursor.h"
19-
#include "webrtc/system_wrappers/interface/compile_assert.h"
2020
#include "webrtc/system_wrappers/interface/logging.h"
2121
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
2222
#include "webrtc/typedefs.h"

webrtc/modules/media_file/source/media_file_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*/
1010

1111
#include "testing/gtest/include/gtest/gtest.h"
12+
#include "webrtc/base/compile_assert.h"
1213
#include "webrtc/modules/media_file/interface/media_file.h"
13-
#include "webrtc/system_wrappers/interface/compile_assert.h"
1414
#include "webrtc/system_wrappers/interface/sleep.h"
1515
#include "webrtc/test/testsupport/fileutils.h"
1616
#include "webrtc/test/testsupport/gtest_disable.h"

webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
#include "testing/gmock/include/gmock/gmock.h"
1616
#include "testing/gtest/include/gtest/gtest.h"
17+
#include "webrtc/base/compile_assert.h"
1718
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h"
1819
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h"
19-
#include "webrtc/system_wrappers/interface/compile_assert.h"
2020
#include "webrtc/typedefs.h"
2121

2222
#define CHECK_ARRAY_SIZE(expected_size, array) \

webrtc/system_wrappers/BUILD.gn

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ static_library("system_wrappers") {
2121
"interface/aligned_malloc.h",
2222
"interface/atomic32.h",
2323
"interface/clock.h",
24-
"interface/compile_assert.h",
2524
"interface/condition_variable_wrapper.h",
2625
"interface/cpu_info.h",
2726
"interface/cpu_features_wrapper.h",

webrtc/system_wrappers/interface/compile_assert.h

-90
This file was deleted.

webrtc/system_wrappers/interface/scoped_ptr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@
104104

105105
#include <algorithm> // For std::swap().
106106

107+
#include "webrtc/base/compile_assert.h"
107108
#include "webrtc/base/constructormagic.h"
108109
#include "webrtc/base/move.h"
109-
#include "webrtc/system_wrappers/interface/compile_assert.h"
110110
#include "webrtc/system_wrappers/interface/template_util.h"
111111
#include "webrtc/typedefs.h"
112112

0 commit comments

Comments
 (0)