Skip to content
This repository has been archived by the owner on Apr 6, 2019. It is now read-only.

Fix std::atomic compilation errors (C2797) on msvc 2013 (again) #3

Merged
merged 1 commit into from
Feb 5, 2017
Merged

Fix std::atomic compilation errors (C2797) on msvc 2013 (again) #3

merged 1 commit into from
Feb 5, 2017

Conversation

navossoc
Copy link
Contributor

@navossoc navossoc commented Feb 5, 2017

I think this will be the best fix for this (painful) issue.

Consider the following example:

class SomeClass
{
	std::atomic_bool test1 = ATOMIC_VAR_INIT(false);	// Fails on VS 2013 (C2797)
	std::atomic<bool> test2 = ATOMIC_VAR_INIT(false);	// Works on VS 2013 and VS 2015
};

VS 2015 defines atomic_bool type on atomic header like this:

// ATOMIC TYPEDEFS
typedef atomic<bool> atomic_bool;

So using fully specialized templates will help in this case.
This will work on both versions and don't thrown any warning on osx + clang.

I have tested this against Visual Studio 2013 Update 5 and Visual Studio 2015 Update 3, both are building fine.

Seems that atomic_bool was a bet for C language, but as this is a C++ library I don't think this change will be an issue.

For further reference:
http://comp.std.cpp.narkive.com/nwMakWji/std-atomic-bool-vs-std-atomic-bool

PS: I'll do the same for cpp_redis.

Avoid using typedef names over full specialization.
@Cylix
Copy link
Owner

Cylix commented Feb 5, 2017

Awesome dude!
Really thanks a lot!
I just tested, it works perfectly fine, so if you tell me that it solves the windows issue, that's perfect :)

@Cylix Cylix merged commit 4c01116 into Cylix:master Feb 5, 2017
@navossoc navossoc deleted the fix_atomic2 branch February 26, 2017 03:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants