Skip to content

Instantly share code, notes, and snippets.

@EricWF
Last active May 1, 2020 00:22
Show Gist options
  • Save EricWF/0c62c271f6c3912df8b04cb639904707 to your computer and use it in GitHub Desktop.
Save EricWF/0c62c271f6c3912df8b04cb639904707 to your computer and use it in GitHub Desktop.
// RUN: $CXX -c %s -o /tmp/first.o -std=c++17 -g
// RUN: $CXX -c %s -o /tmp/second.o -std=c++17 -g -DWITH_MAIN
// RUN: $CXX -o /tmp/test.out /tmp/first.o /tmp/second.o
// RUN: /tmp/test.out
#include <cassert>
#define ABSL_INTERNAL_UNIQUE_SMALL_NAME2(x) #x
#define ABSL_INTERNAL_UNIQUE_SMALL_NAME1(x) ABSL_INTERNAL_UNIQUE_SMALL_NAME2(x)
#define ABSL_INTERNAL_UNIQUE_SMALL_NAME() \
asm(ABSL_INTERNAL_UNIQUE_SMALL_NAME1(.absl123456.__COUNTER__))
int t1();
int t2();
#ifdef WITH_MAIN
namespace foo
{
inline int bar() ABSL_INTERNAL_UNIQUE_SMALL_NAME();
inline int bar() {
return 42;
}
}
int t1() { return foo::bar(); }
#else
namespace other
{
inline int func() ABSL_INTERNAL_UNIQUE_SMALL_NAME();
inline int func() {
return 101;
}
}
int t2() { return other::func(); }
#endif
#ifdef WITH_MAIN
int main() {
assert(t1() != t2());
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment