diff options
author | brucedawson <brucedawson@chromium.org> | 2015-11-03 16:48:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-04 00:49:41 +0000 |
commit | 599857c9a6a07024a6047080f91f71f801deb4f8 (patch) | |
tree | ab988d17a88795e575739472161d2d3475b8fde0 | |
parent | 9b63774131d82586404c27c60e6aff0c63babbda (diff) | |
download | chromium_src-599857c9a6a07024a6047080f91f71f801deb4f8.zip chromium_src-599857c9a6a07024a6047080f91f71f801deb4f8.tar.gz chromium_src-599857c9a6a07024a6047080f91f71f801deb4f8.tar.bz2 |
Avoid const int definition problems
VC++ up to VS 2015 RTM does not require explicit storage allocation for
static const integers declared in classes. VS 2015 Update 1 requires
these storage definitions in some cases. In order to avoid #ifs
around the storage definitions this change switches the problematic
consts to enums, for maximum portability.
Where needed the enums have types specified.
Many previous versions of VC++ have theoretically *allowed* a
definition to supply storage, but tests on VC++ 2013 show that this
doesn't actually work correctly - it leads to duplicate definition
errors. So, enums are the only #if option.
With this change all targets build with the latest VS 2015.
See also 1422453005.
R=danakj@chromium.org,zmo@chromium.org
BUG=440500
Review URL: https://codereview.chromium.org/1428003002
Cr-Commit-Position: refs/heads/master@{#357688}
-rw-r--r-- | base/time/time.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/client/fenced_allocator.cc | 5 | ||||
-rw-r--r-- | gpu/command_buffer/client/fenced_allocator.h | 4 | ||||
-rw-r--r-- | ui/gfx/icon_util.h | 4 |
4 files changed, 5 insertions, 10 deletions
diff --git a/base/time/time.h b/base/time/time.h index 8da08ff..4944085 100644 --- a/base/time/time.h +++ b/base/time/time.h @@ -421,7 +421,7 @@ class BASE_EXPORT Time : public time_internal::TimeBase<Time> { // To avoid overflow in QPC to Microseconds calculations, since we multiply // by kMicrosecondsPerSecond, then the QPC value should not exceed // (2^63 - 1) / 1E6. If it exceeds that threshold, we divide then multiply. - static const int64 kQPCOverflowThreshold = 0x8637BD05AF7; + enum : int64 { kQPCOverflowThreshold = 0x8637BD05AF7 }; #endif // Represents an exploded time that can be formatted nicely. This is kind of diff --git a/gpu/command_buffer/client/fenced_allocator.cc b/gpu/command_buffer/client/fenced_allocator.cc index 726fe7d..7f34e58 100644 --- a/gpu/command_buffer/client/fenced_allocator.cc +++ b/gpu/command_buffer/client/fenced_allocator.cc @@ -27,11 +27,6 @@ unsigned int RoundUp(unsigned int size) { } // namespace -#ifndef _MSC_VER -const FencedAllocator::Offset FencedAllocator::kInvalidOffset; -const unsigned int FencedAllocator::kAllocAlignment; -#endif - FencedAllocator::FencedAllocator(unsigned int size, CommandBufferHelper* helper) : helper_(helper), bytes_in_use_(0) { Block block = { FREE, 0, RoundDown(size), kUnusedToken }; diff --git a/gpu/command_buffer/client/fenced_allocator.h b/gpu/command_buffer/client/fenced_allocator.h index 95dccce..45b4dfd 100644 --- a/gpu/command_buffer/client/fenced_allocator.h +++ b/gpu/command_buffer/client/fenced_allocator.h @@ -33,10 +33,10 @@ class GPU_EXPORT FencedAllocator { public: typedef unsigned int Offset; // Invalid offset, returned by Alloc in case of failure. - static const Offset kInvalidOffset = 0xffffffffU; + enum : Offset { kInvalidOffset = 0xffffffffU }; // Allocation alignment, must be a power of two. - static const unsigned int kAllocAlignment = 16; + enum : unsigned int { kAllocAlignment = 16 }; // Creates a FencedAllocator. Note that the size of the buffer is passed, but // not its base address: everything is handled as offsets into the buffer. diff --git a/ui/gfx/icon_util.h b/ui/gfx/icon_util.h index 1a48304..46ac3f9 100644 --- a/ui/gfx/icon_util.h +++ b/ui/gfx/icon_util.h @@ -64,11 +64,11 @@ class GFX_EXPORT IconUtil { // default for historical reasons. enum WriteType { ATOMIC_WRITE, NORMAL_WRITE }; // The size of the large icon entries in .ico files on Windows Vista+. - static const int kLargeIconSize = 256; + enum { kLargeIconSize = 256 }; // The size of icons in the medium icons view on Windows Vista+. This is the // maximum size Windows will display an icon that does not have a 256x256 // image, even at the large or extra large icons views. - static const int kMediumIconSize = 48; + enum { kMediumIconSize = 48 }; // The dimensions for icon images in Windows icon files. All sizes are square; // that is, the value 48 means a 48x48 pixel image. Sizes are listed in |