1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef RTC_BASE_ARRAYSIZE_H_ 12*d9f75844SAndroid Build Coastguard Worker #define RTC_BASE_ARRAYSIZE_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #include <stddef.h> 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker // This file defines the arraysize() macro and is derived from Chromium's 17*d9f75844SAndroid Build Coastguard Worker // base/macros.h. 18*d9f75844SAndroid Build Coastguard Worker 19*d9f75844SAndroid Build Coastguard Worker // The arraysize(arr) macro returns the # of elements in an array arr. 20*d9f75844SAndroid Build Coastguard Worker // The expression is a compile-time constant, and therefore can be 21*d9f75844SAndroid Build Coastguard Worker // used in defining new arrays, for example. If you use arraysize on 22*d9f75844SAndroid Build Coastguard Worker // a pointer by mistake, you will get a compile-time error. 23*d9f75844SAndroid Build Coastguard Worker 24*d9f75844SAndroid Build Coastguard Worker // This template function declaration is used in defining arraysize. 25*d9f75844SAndroid Build Coastguard Worker // Note that the function doesn't need an implementation, as we only 26*d9f75844SAndroid Build Coastguard Worker // use its type. 27*d9f75844SAndroid Build Coastguard Worker template <typename T, size_t N> 28*d9f75844SAndroid Build Coastguard Worker char (&ArraySizeHelper(T (&array)[N]))[N]; 29*d9f75844SAndroid Build Coastguard Worker 30*d9f75844SAndroid Build Coastguard Worker #define arraysize(array) (sizeof(ArraySizeHelper(array))) 31*d9f75844SAndroid Build Coastguard Worker 32*d9f75844SAndroid Build Coastguard Worker #endif // RTC_BASE_ARRAYSIZE_H_ 33