I have some C++ code in visual studio 2015 that compiles and works fine on my machine, but not on my team mate's.
We have the exact same code base, and the exact same versions of all the same libraries, but on his machine, Visual Studio fails to properly resolve some macros of templates correctly, while mine works just fine.
I'm trying to recreate his build environment so I can reproduce the issue. We're both using visual studio 15 update 3 Version 14.0.25431.01 , but the Visual C++ 2015 versions are different, but I can't find a way to specify the version I'd like visual studio to use.
How do I do so? And in general, how do I ensure our build environments are consistent in visual studio?
EDIT: To pull in some further info from the comments on what we've done so far:
- We're both using the exact same version of visual studio 2015 (update 3 Version 14.0.25431.01)
- Ensuring our libraries are relative to the solution directory and are downloaded along with the project repo so there's no wrong paths
- Included the project files and solution in the repo and ensured they have the same
- Target Platform Version (Windows SDK version) : Windows 8.1
- Platform toolset : Visual Studio 2015 (v140)
EDIT: As @Marek R mentioned, I should include the exact error I was having: I'm trying to do some signal processing with the Eigen library.
The exact line it crashes on tries to initialise an array as so:
Eigen::ArrayX<int> foo(size_of_the_array)
then use that array as so:
foo(index) = bar
Eigen uses a macro over template using statements to redefine this type as to:
Eigen::Array<int,-1,1>
This works as expected on my machine, but when trying to compile on his, it fails
3>HighRes.cpp(187): error C2514: 'Eigen::Array<int,-1,1,,-1,1>': class has no constructors
3> c:\WORKING_DIR\sigproc_vs2015\eigen\eigen\src/Core/Array.h(46): note: see declaration of 'Eigen::Array<int,-1,1,,-1,1>' 3>HighRes.cpp(188): error C2039: 'size': is not a member of 'Eigen::Array<int,-1,1,,-1,1>'
3> c:\WORKING_DIR\sigproc_vs2015\eigen\eigen\src/Core/Array.h(46): note: see declaration of 'Eigen::Array<int,-1,1,,-1,1>' 3>HighRes.cpp(188): error C2039: '__this': is not a member of 'Eigen::Array<int,-1,1,,-1,1>'
3> c:\WORKING_DIR\sigproc_vs2015\eigen\eigen\src/Core/Array.h(46): note: see declaration of 'Eigen::Array<int,-1,1,,-1,1>' 3>HighRes.cpp(189): error C2064: term does not evaluate to a function taking 1 arguments
What's even more strange is other sections of the code have similar calls to this macro, but with other types eg: Eigen::ArrayX<bool> baz(some_other_size);
and his build doesn't complain about those. I'm trying to reproduce this behavior on mine.
UPDATE: I've had a chance to play with his machine a little more, and I notice a couple of things:
1: His machine is fine instantiating Eigen::ArrayX<T>
anywhere else, apart from the specific section of the code the that failed to build earlier
2: The only thing special about that specific section is it's is inside a closure
auto process_in_parallel = [state](int dimension){
// Other code...
Eigen::ArrayX<int> foo(size_of_the_array);
3: Eigen uses nested macros to define template using statements which define the ArrayX class.
I've actually had a lot of trouble getting visual studio 15 to work with template using statements and nested template classes; the compiler would often crash and just ask me to simplify my code around a given line.
I'm happy to just work around this by changing the definition to Eigen::ArrayXi
; a non-template type alias. This compiles just fine, and the build passes all tests.