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

Unified Diff: third_party/mojo/src/mojo/public/cpp/system/macros.h

Issue 1127293003: Update mojo sdk to rev f84766d3b6420b7cf6a113d9d65d73cb5fe18d90 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatting Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/cpp/system/macros.h
diff --git a/third_party/mojo/src/mojo/public/cpp/system/macros.h b/third_party/mojo/src/mojo/public/cpp/system/macros.h
index 8c7998961fc2b86df11a7ac64b49ba2d729c6c3f..9836e99f369b82a4b5e056b18eb17a56f34424c2 100644
--- a/third_party/mojo/src/mojo/public/cpp/system/macros.h
+++ b/third_party/mojo/src/mojo/public/cpp/system/macros.h
@@ -42,4 +42,27 @@ char(&ArraySizeHelper(const T(&array)[N]))[N];
typedef void MoveOnlyTypeForCPP03; \
\
private:
+
+// 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. Use like:
+//
+// In .h file:
+// struct Foo {
+// static const int kBar = 5;
+// };
+//
+// In .cc file:
+// STATIC_CONST_MEMBER_DEFINITION const int Foo::kBar;
+#if defined(_MSC_VER)
+#define MOJO_STATIC_CONST_MEMBER_DEFINITION __declspec(selectany)
+#else
+#define MOJO_STATIC_CONST_MEMBER_DEFINITION
+#endif
+
#endif // MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_
« no previous file with comments | « third_party/mojo/src/mojo/public/cpp/environment/logging.h ('k') | third_party/mojo/src/mojo/public/dart/src/codec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698