Remove MOJO_STATIC_CONST_MEMBER_DEFINITION. R=jamesr@chromium.org Review URL: https://codereview.chromium.org/1770493002 .
diff --git a/mojo/edk/system/channel_endpoint_id.cc b/mojo/edk/system/channel_endpoint_id.cc index 9a13837..aa89a9f 100644 --- a/mojo/edk/system/channel_endpoint_id.cc +++ b/mojo/edk/system/channel_endpoint_id.cc
@@ -7,8 +7,7 @@ namespace mojo { namespace system { -MOJO_STATIC_CONST_MEMBER_DEFINITION const uint32_t - ChannelEndpointId::kRemoteFlag; +const uint32_t ChannelEndpointId::kRemoteFlag; ChannelEndpointId LocalChannelEndpointIdGenerator::GetNext() { ChannelEndpointId rv = next_;
diff --git a/mojo/edk/system/message_in_transit.cc b/mojo/edk/system/message_in_transit.cc index 6e270b9..26e9252 100644 --- a/mojo/edk/system/message_in_transit.cc +++ b/mojo/edk/system/message_in_transit.cc
@@ -17,8 +17,7 @@ namespace mojo { namespace system { -MOJO_STATIC_CONST_MEMBER_DEFINITION const size_t - MessageInTransit::kMessageAlignment; +const size_t MessageInTransit::kMessageAlignment; struct MessageInTransit::PrivateStructForCompileAsserts { // The size of |Header| must be a multiple of the alignment.
diff --git a/mojo/edk/system/transport_data.cc b/mojo/edk/system/transport_data.cc index 8d06019..fedfce6 100644 --- a/mojo/edk/system/transport_data.cc +++ b/mojo/edk/system/transport_data.cc
@@ -30,10 +30,8 @@ 0, "kMaxSizePerPlatformHandle not a multiple of alignment"); -MOJO_STATIC_CONST_MEMBER_DEFINITION const size_t - TransportData::kMaxSerializedDispatcherSize; -MOJO_STATIC_CONST_MEMBER_DEFINITION const size_t - TransportData::kMaxSerializedDispatcherPlatformHandles; +const size_t TransportData::kMaxSerializedDispatcherSize; +const size_t TransportData::kMaxSerializedDispatcherPlatformHandles; // static size_t TransportData::GetMaxBufferSize() {
diff --git a/mojo/public/cpp/system/macros.h b/mojo/public/cpp/system/macros.h index 2b6fba8..0fb076f 100644 --- a/mojo/public/cpp/system/macros.h +++ b/mojo/public/cpp/system/macros.h
@@ -64,29 +64,6 @@ type(const type&) = delete; \ void operator=(const type&) = delete -// The C++ standard requires that static const members have an out-of-class -// definition (in a single compilation unit), but MSVC chokes on this (when -// language extensions, which are required, are enabled). (You're only likely to -// notice the need for a definition if you take the address of the member or, -// more commonly, pass it to a function that takes it as a reference argument -- -// probably an STL function.) This macro makes MSVC do the right thing. See -// http://msdn.microsoft.com/en-us/library/34h23df8(v=vs.100).aspx for more -// information. This workaround does not appear to be necessary after VS2015. -// Use like: -// -// In the .h file: -// struct Foo { -// static const int kBar = 5; -// }; -// -// In the .cc file: -// MOJO_STATIC_CONST_MEMBER_DEFINITION const int Foo::kBar; -#if defined(_MSC_VER) && _MSC_VER < 1900 -#define MOJO_STATIC_CONST_MEMBER_DEFINITION __declspec(selectany) -#else -#define MOJO_STATIC_CONST_MEMBER_DEFINITION -#endif - namespace mojo { // Used to explicitly mark the return value of a function as unused. (Use this
diff --git a/mojo/public/cpp/system/tests/macros_unittest.cc b/mojo/public/cpp/system/tests/macros_unittest.cc index ab4ca80..8ee8490 100644 --- a/mojo/public/cpp/system/tests/macros_unittest.cc +++ b/mojo/public/cpp/system/tests/macros_unittest.cc
@@ -19,19 +19,6 @@ #include "testing/gtest/include/gtest/gtest.h" namespace mojo { - -// The test for |MOJO_STATIC_CONST_MEMBER_DEFINITION| is really a compile/link -// test. To test it fully would really require a header file and multiple .cc -// files, but we'll just cursorily verify it. -// -// This is defined outside of an anonymous namespace because -// MOJO_STATIC_CONST_MEMBER_DEFINITION may not be used on internal symbols. -struct StructWithStaticConstMember { - static const int kStaticConstMember = 123; -}; -MOJO_STATIC_CONST_MEMBER_DEFINITION -const int StructWithStaticConstMember::kStaticConstMember; - namespace { // Note: MSVS is very strict (and arguably buggy) about warnings for classes @@ -140,12 +127,6 @@ EXPECT_EQ(123, z.value()); } -// Use it, to make sure things get linked in and to avoid any warnings about -// unused things. -TEST(MacrosCppTest, StaticConstMemberDefinition) { - EXPECT_EQ(123, StructWithStaticConstMember::kStaticConstMember); -} - // The test for |ignore_result()| is also just a compilation test. (Note that // |MOJO_WARN_UNUSED_RESULT| can only be used in the prototype. int ReturnsIntYouMustUse() MOJO_WARN_UNUSED_RESULT;
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl index 199e6ac..0b5f8a8 100644 --- a/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl +++ b/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
@@ -31,16 +31,16 @@ {#--- Begin #} {%- if interface.service_name %} -MOJO_STATIC_CONST_MEMBER_DEFINITION const char {{class_name}}::Name_[] = "{{interface.service_name}}"; +const char {{class_name}}::Name_[] = "{{interface.service_name}}"; {%- endif %} -MOJO_STATIC_CONST_MEMBER_DEFINITION const uint32_t {{class_name}}::Version_; +const uint32_t {{class_name}}::Version_; {#--- Constants #} {%- for constant in interface.constants %} {%- if constant.kind|is_integral_kind %} -MOJO_STATIC_CONST_MEMBER_DEFINITION const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}}; +const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}}; {%- else %} -MOJO_STATIC_CONST_MEMBER_DEFINITION const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}} = {{constant|constant_value}}; +const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}} = {{constant|constant_value}}; {%- endif %} {%- endfor %}
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl index 50c7f1a..7598f96 100644 --- a/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl +++ b/mojo/public/tools/bindings/generators/cpp_templates/module.cc.tmpl
@@ -79,9 +79,9 @@ {%- for struct in structs %} {%- for constant in struct.constants %} {%- if constant.kind|is_integral_kind %} -MOJO_STATIC_CONST_MEMBER_DEFINITION const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}}; +const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}}; {%- else %} -MOJO_STATIC_CONST_MEMBER_DEFINITION const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}} = {{constant|constant_value}}; +const {{constant.kind|cpp_pod_type}} {{struct.name}}::{{constant.name}} = {{constant|constant_value}}; {%- endif %} {%- endfor %} {%- endfor %}