Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: base/macros.h

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/mac/foundation_util_unittest.mm ('k') | base/md5.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains macros and macro-like constructs (e.g., templates) that 5 // This file contains macros and macro-like constructs (e.g., templates) that
6 // are commonly used throughout Chromium source. (It may also contain things 6 // are commonly used throughout Chromium source. (It may also contain things
7 // that are closely related to things that are commonly used that belong in this 7 // that are closely related to things that are commonly used that belong in this
8 // file.) 8 // file.)
9 9
10 #ifndef BASE_MACROS_H_ 10 #ifndef BASE_MACROS_H_
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // use its type. 48 // use its type.
49 template <typename T, size_t N> char (&ArraySizeHelper(T (&array)[N]))[N]; 49 template <typename T, size_t N> char (&ArraySizeHelper(T (&array)[N]))[N];
50 #define arraysize(array) (sizeof(ArraySizeHelper(array))) 50 #define arraysize(array) (sizeof(ArraySizeHelper(array)))
51 51
52 // bit_cast<Dest,Source> is a template function that implements the 52 // bit_cast<Dest,Source> is a template function that implements the
53 // equivalent of "*reinterpret_cast<Dest*>(&source)". We need this in 53 // equivalent of "*reinterpret_cast<Dest*>(&source)". We need this in
54 // very low-level functions like the protobuf library and fast math 54 // very low-level functions like the protobuf library and fast math
55 // support. 55 // support.
56 // 56 //
57 // float f = 3.14159265358979; 57 // float f = 3.14159265358979;
58 // int i = bit_cast<int32>(f); 58 // int i = bit_cast<int32_t>(f);
59 // // i = 0x40490fdb 59 // // i = 0x40490fdb
60 // 60 //
61 // The classical address-casting method is: 61 // The classical address-casting method is:
62 // 62 //
63 // // WRONG 63 // // WRONG
64 // float f = 3.14159265358979; // WRONG 64 // float f = 3.14159265358979; // WRONG
65 // int i = * reinterpret_cast<int*>(&f); // WRONG 65 // int i = * reinterpret_cast<int*>(&f); // WRONG
66 // 66 //
67 // The address-casting method actually produces undefined behavior 67 // The address-casting method actually produces undefined behavior
68 // according to ISO C++ specification section 3.10 -15 -. Roughly, this 68 // according to ISO C++ specification section 3.10 -15 -. Roughly, this
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 // Use these to declare and define a static local variable (static T;) so that 144 // Use these to declare and define a static local variable (static T;) so that
145 // it is leaked so that its destructors are not called at exit. If you need 145 // it is leaked so that its destructors are not called at exit. If you need
146 // thread-safe initialization, use base/lazy_instance.h instead. 146 // thread-safe initialization, use base/lazy_instance.h instead.
147 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \ 147 #define CR_DEFINE_STATIC_LOCAL(type, name, arguments) \
148 static type& name = *new type arguments 148 static type& name = *new type arguments
149 149
150 } // base 150 } // base
151 151
152 #endif // BASE_MACROS_H_ 152 #endif // BASE_MACROS_H_
OLDNEW
« no previous file with comments | « base/mac/foundation_util_unittest.mm ('k') | base/md5.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698