Skip to content

Instantly share code, notes, and snippets.

@EricWF
Created April 30, 2020 22:53
Show Gist options
  • Save EricWF/71170c173bdca4825065817992507ce7 to your computer and use it in GitHub Desktop.
Save EricWF/71170c173bdca4825065817992507ce7 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>
namespace {
__attribute__((noinline))
int bar() asm(".my-name");
__attribute__((noinline))
int bar() {
#ifdef WITH_MAIN
return 42;
#else
return 101;
#endif
}
}
int t1();
int t2();
#ifdef WITH_MAIN
int t1() { return bar(); }
#else
int t2() { return bar(); }
#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