Visual Studio 2013에서 작동하는 데 사용하는 코드가 있습니다. Visual Studio 2017에서 동일한 코드를 작성하려고하기 때문에 불평합니다. 여기에 내가하려고하는 코드가있다. 이와 원자 C++에 대해 삭제 된 함수를 참조하려고 시도했습니다.
#include <array>
#include <atomic>
int main()
{
using TrdRobotStateArray = std::array<std::atomic<double>, 6>;
TrdRobotStateArray mCurrentPose = { 0.3 };
printf("%0.3f", mCurrentPose[0]);
return 0;
}
, 나는이 오류 얻을 :이 코드를 작성하지 않은
error C2280: 'std::atomic<double>::atomic(const std::atomic<double> &)': attempting to reference a deleted function
을, 나는 원자 변수로 읽어 것을 시도하고있다. 그러나 나는 여전히 그 오류로 어떤 일이 벌어지고 있는지 확실히 모른다. atomics에 대한 설명은 크게 감사하겠습니다. 감사!
갱신 : 여기
모든 오류 및 코드와 함께 경고입니다. 그래서 그것은 미래에 다른 사람들을 도울 것입니다.
1>AtomicTest.cpp
1>AtomicTest.cpp(13): error C4839: non-standard use of class
'std::atomic<double>' as an argument to a variadic function
1>AtomicTest.cpp(13): note: the constructor and destructor will not be
called; a bitwise copy of the class will be passed as the argument
1>AtomicTest.cpp(11): note: see declaration of 'std::atomic<double>'
1>AtomicTest.cpp(13): error C2280: 'std::atomic<double>::atomic(const
std::atomic<double> &)': attempting to reference a deleted function
1>C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\atomic(689):
note: see declaration of 'std::atomic<double>::atomic'
1>C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.11.25503\include\atomic(689):
note: 'std::atomic<double>::atomic(const std::atomic<double> &)': function
was explicitly deleted
1>AtomicTest.cpp(13): warning C4477: 'printf' : format string '%0.3f'
requires an argument of type 'double', but variadic argument 1 has type
'std::atomic<double>'
1>Done building project "AtomicTest.vcxproj" -- FAILED.
잠깐 ... 실제로이 코드에 대한 첫 번째 오류 메시지는 '오류 C4839 : 표준 외의 클래스'std :: atomic '을 가변 인수 함수의 인수로 사용합니다.'입니다. 컴파일러를 어떻게 호출합니까? –
추신 : 향상된 오류 메시지가 Visual C++ 2017의 최신 버전에 추가 된 것 같습니다. https://docs.microsoft.com/en-us/cpp/cpp-conformance-improvements-2017을 참조하십시오. 최신 버전으로 업그레이드 할 수 있습니다. –
그래, 나는 그 오류도 받지만 Jodocus 수정을 적용하자마자 사라졌다. 나는 그것에 대해 걱정해야합니까? –