Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking Error: multiple definition of ptc::__print__::mutex_ and ptc::print #5

Closed
MiiKaa3 opened this issue Aug 2, 2022 · 0 comments · Fixed by #4
Closed

Linking Error: multiple definition of ptc::__print__::mutex_ and ptc::print #5

MiiKaa3 opened this issue Aug 2, 2022 · 0 comments · Fixed by #4

Comments

@MiiKaa3
Copy link
Contributor

MiiKaa3 commented Aug 2, 2022

I was testing ptc::print in this very simple example:

// -- logerror.hpp
#pragma once
#include "print.hpp"
void logerror(const char*);

// -- logerror.cpp
#include "logerror.hpp"
void logerror(const char* msg)
{
    ptc::print("\033[31m", "[ERROR]:", msg);
    return;
}

// -- main.cpp
#include "print.hpp"
#include "logerror.hpp"
int main()
{
    ptc::print("Hello World!";
    logerror("uh oh, spaghgetti-o");
    return 0;
}

This complies successfully but when it attempts to link, the linker complains about multiple definitions of ptc::__print__::mutex_ and ptc::print which makes sense given that I ostensibly #include print.hpp twice, it leads to two instantiations of the mentioned objects. I think this would successfully and simply be resolved by inling the definitions and declarations of those objects.

@MiiKaa3 MiiKaa3 changed the title Linking Error: multiple definition of ptc::__print__::mutex_ and ptc::print' Linking Error: multiple definition of ptc::__print__::mutex_ and ptc::print Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant