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

VS2013 compile error when you define the static const variable in class of head file #29

Open
WindyPaper opened this issue Jan 12, 2017 · 3 comments

Comments

@WindyPaper
Copy link

WindyPaper commented Jan 12, 2017

hi, when I fork your renderer and compile it with VS2013 on Windows, I found the compiler will encounter error of "the xxx(variable) already defined in core.lib". I think maybe the reason is you defined the variable in the head file and give them a value. Many people will give them value in cpp usually that won't cause these errors.
Such as: the class "FileInputStreambuf" in FileStreamBuf.hpp have declared the varable "static CONSTEXPR size_t PutBackSize = 8", if FileUtil.cpp include this head file, when other files also include this head file, the compile will encounter the error of redefined.
I want to know how you solve this error in your project, thank you very much!

@tunabrain
Copy link
Owner

Hi,

I tested locally on VS2013 and VS2015, but did not encounter the same error. I also set up automated VS2013 builds recently to make sure, but the builds succeed. Is it possible that you modified the project, or do these errors also occur in a freshly cloned repository?

@WindyPaper
Copy link
Author

Thanks for your reply. I do these errors in a freshly cloned repository. Maybe there are little different settings in my environment. I will test whether this error will encounter on VS2015.

@mmmovania
Copy link

mmmovania commented Feb 18, 2017

Yeah I am also getting the same (symbol already defined linker errors) on the latest (master) branch in VS2013. I am compilimg using vs2013 ultimate on Windows 8.1 64-bit. The code compiles and builds without errors on VS2015.

On VS2013, the solution is to comment the constant declaration line inside the namespace tungsten in the .cpp file. For example, in BitManip.cpp file

#include "BitManip.hpp"

#include <cmath>

namespace Tungsten {

//CONSTEXPR uint32 BitManip::LogMantissaBits; //comment this line

std::unique_ptr<float[]> BitManip::_logLookup;

BitManip::Initializer BitManip::initializer;

Just a suggestion, would it be better to put the TILE_SIZE variable in the parent class (Integrator) rather than declaring and defining in each child class?

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

3 participants