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

MSVC not compiling when including "rang.hpp" #63

Closed
tatjam opened this issue May 26, 2017 · 9 comments
Closed

MSVC not compiling when including "rang.hpp" #63

tatjam opened this issue May 26, 2017 · 9 comments
Assignees

Comments

@tatjam
Copy link

tatjam commented May 26, 2017

I'm not sure what am I doing wrong but whenever I include "rang.hpp" outside of Main.cpp i get this compile error:

error LNK2005: "void * __cdecl rang::rang_implementation::getVersionDependentHandle(void)" (?getVersionDependentHandle@rang_implementation@rang@@YAPAXXZ) already defined in [Wathever].obj

Any idea what is happening and how could I fix it?

@tatjam
Copy link
Author

tatjam commented May 26, 2017

By the way I manually fixed it in my code by basically putting the "getVersionDependentHandle" code everywhere is it called, doing the inlining for the compiler! That works properly but may be interesting to look into this error. (Also commented the getVersionDependentHandle function)

@agauniyal
Copy link
Owner

agauniyal commented May 27, 2017

@tatjam Thankyou for the bug report as well as your solution for it. Could you try one thing and put inline in front of getVersionDependentHandle method ie. the line number 178 should be -

inline HANDLE getVersionDependentHandle()

This should fix the error and if your program builds, I'll commit the change :)

@agauniyal agauniyal self-assigned this May 27, 2017
@tatjam
Copy link
Author

tatjam commented May 27, 2017

Alright I will try it, will reply in a moment

@tatjam
Copy link
Author

tatjam commented May 27, 2017

Well, this is strange! Writing inline before it worked, but required me to do the same onvoid rang_init() too. Upon these changes it works... I suppose this is a compiler bug more than a rang error.

@tatjam
Copy link
Author

tatjam commented May 27, 2017

Will try to compile on gcc with both the original and the modified version to see if this has to do with MSVC (I suppose it does)

EDIT: Sadly compiling with gcc (on windows) is not easily done with mingw, but I suppose adding these inlines should not break compiling on stuff different from MSVC

@agauniyal
Copy link
Owner

Don't worry about gcc and clang compilers, I'll test them myself 😸 . I don't have an windows machine or vm image nearby otherwise I would've tested it myself. I'll download the vm image again but it'll take some time(20+ GB on 8Mb/sec connection 😂 ).

Just tell me the minimum modifications you did to solve the problem and I'll run the tests on different sets of compilers 👍 . Thanks!

@agauniyal
Copy link
Owner

agauniyal commented May 28, 2017

isn't void init() method already inlined - https://github.com/agauniyal/rang/blob/master/include/rang.hpp#L259 ?

Also sorry for lack of proper documentation, but you don't need to call init() method unless you're redirecting the cout/cerr/clog to somewhere else.

@tatjam
Copy link
Author

tatjam commented May 28, 2017

Oh I downloaded it from "Releases", instead of directly from the repo. Indeed the file on the repo is correct.

It just requires to put an inline behind the getVersionDependentHandle() function and it works beautifully! :)

@agauniyal
Copy link
Owner

agauniyal commented May 28, 2017

@tatjam I've uploaded a new release with right changes - https://github.com/agauniyal/rang/releases/tag/2.1. I hope it builds easily now and you make something cool out of it 🎉 .

I'll be closing this issue but feel free to reopen if something doesn't works as expected 😄 .

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

No branches or pull requests

2 participants