-
Notifications
You must be signed in to change notification settings - Fork 115
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
Build fixups for Visual Studio 2015 #95
Build fixups for Visual Studio 2015 #95
Conversation
Signed-off-by: Nigel Stewart <[email protected]>
|
In relation to: c42f/displaz#197 |
Perhaps an alternative fix is to add initializers for x, y, z? We're working to constexpr as much as possible. |
For some further data-points, I built mainline Imath for Visual Studio 2013, 2015, 2017 and 2019 To summarise:
Perhaps then initializers could be #ifdeffed for Visual Studio 14 2015, as a workaround without affecting runtimes elsewhere? |
The historic argument for not having those fields initialized was that in the days of VS200x, and gcc 2 and 3, writing code like this: Imath::V3f x = Imath::V3f(1,2,3); would generate extra instructions; it would initialize x with (0,0,0), then it would copy over those values. In performance bound loops, the extra zeroing added measurable slow down. Nowadays, I'm sure that the emitted code would be to initialize x directly with (1,2,3). I would expect that VS2015, being a much improved compiler over any of VS200x, also does the minimum work. I'd like to solicit input from those working in Imath recently, but my suggestion is that we just add zero initializers. |
I think we need to also be super careful about idioms like
that would incur traversing the whole array initializing, perhaps needlessly. |
Oh gosh, you're right. That's an unpleasant trap. https://stackoverflow.com/questions/5958572/how-can-i-avoid-stdvector-to-initialize-all-its-elements |
I think this patch is correct -- we should not have marked I do also notice that the constructor from a single scalar,
can be
to
and similarly, the Vec3 constructors from (T a, T b, T c) and const Vec3& can also be C++11 constexpr by using the member initializer syntax rather than multiple assignment statements. |
I took Larry's suggestion and constexpr-ed the Vec2, Vec3, and Vec4 constructors by using member initializers, see #98. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
In the process of migrating from ilmbase we came across some compiler errors for Visual Studio on Windows.
https://ci.appveyor.com/project/nigels-com/displaz/builds/37721083
This change works for both Visual Studio 2015 and 2017:
https://ci.appveyor.com/project/nigels-com/imath/builds/37723230
As an aside, I noticed that Vec2 didn't seem to have the constexpr there for Vec3 and Vec4.