-
-
Save pitrou/1c892d1c42bd6ece9b68a9eb015b76c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -exuo pipefail | |
# CXXFLAGS=${CXXFLAGS//-fvisibility-inlines-hidden/} | |
${CXX} ${CXXFLAGS} ${LDFLAGS} -shared -DNDEBUG -o libtest.so lib.cpp | |
nm --demangle --defined-only libtest.so | grep Test | |
${CXX} ${CXXFLAGS} ${LDFLAGS} -L$(pwd) -g -DNDEBUG -o main-release main.cpp -ltest | |
LD_LIBRARY_PATH=$(pwd) ./main-release | |
${CXX} ${CXXFLAGS} ${LDFLAGS} -L$(pwd) -g -o main-debug main.cpp -ltest | |
LD_LIBRARY_PATH=$(pwd) ./main-debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lib.h" | |
Test::Test() { | |
this->ptr = new int(8); | |
} | |
#ifndef NDEBUG | |
Test::~Test() { | |
delete this->ptr; | |
} | |
#endif | |
void DoSomething() { | |
// Make sure the destructor is present inside the shared library. | |
static Test test{}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
public: | |
Test(); | |
#ifdef NDEBUG | |
~Test() { | |
delete ptr; | |
} | |
#else | |
~Test(); | |
#endif | |
int* ptr; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lib.h" | |
int main () { | |
Test t = Test(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment