forked from clementine-player/Clementine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// From Chromium src/base/macros.h | ||
|
||
#include <stddef.h> // For size_t. | ||
|
||
// The arraysize(arr) macro returns the # of elements in an array arr. | ||
// The expression is a compile-time constant, and therefore can be | ||
// used in defining new arrays, for example. If you use arraysize on | ||
// a pointer by mistake, you will get a compile-time error. | ||
// | ||
// One caveat is that arraysize() doesn't accept any array of an | ||
// anonymous type or a type defined inside a function. In these rare | ||
// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is | ||
// due to a limitation in C++'s template system. The limitation might | ||
// eventually be removed, but it hasn't happened yet. | ||
|
||
// This template function declaration is used in defining arraysize. | ||
// Note that the function doesn't need an implementation, as we only | ||
// use its type. | ||
template <typename T, size_t N> | ||
char (&ArraySizeHelper(T (&array)[N]))[N]; | ||
|
||
// That gcc wants both of these prototypes seems mysterious. VC, for | ||
// its part, can't decide which to use (another mystery). Matching of | ||
// template overloads: the final frontier. | ||
#ifndef _MSC_VER | ||
template <typename T, size_t N> | ||
char (&ArraySizeHelper(const T (&array)[N]))[N]; | ||
#endif | ||
|
||
#define arraysize(array) (sizeof(ArraySizeHelper(array))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters