/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* ... and then commpile your file with -DMYLIB_VERSION=\"1\"
*/
+
+#ifdef __APPLE__
+// OS X doesn't support constructor priorities. Just pray it works, I guess.
+#define FOLLY_VERSION_CHECK_PRIORITY __attribute__((__constructor__))
+#else
+#define FOLLY_VERSION_CHECK_PRIORITY __attribute__((__constructor__(101)))
+#endif
+
// Note that this is carefully crafted: PRODUCT##Version must have external
// linkage (so it collides among versions), versionCheck must have internal
// linkage (so it does NOT collide between versions); if we're trying to have
#define FOLLY_VERSION_CHECK(PRODUCT, VERSION) \
const char* PRODUCT##Version = VERSION; \
namespace { \
- __attribute__((constructor(101))) void versionCheck() { \
+ FOLLY_VERSION_CHECK_PRIORITY void versionCheck() { \
if (strcmp(PRODUCT##Version, VERSION)) { \
fprintf(stderr, \
"Invalid %s version: desired [%s], currently loaded [%s]\n", \