Jak aktywować standard c++11 w Visual Studio 2017

0

Nie mam włączonego standardu c++11 w visual studio community 2017 i nie mogę znaleźć tego w opcjach.
Wie ktoś może gdzie to znajdę, lub czy muszę przeinstalować VS?

0

Nie wiem czy możliwe jest wyłączenie. Zwykle kompilator zawiera najnowszy zaimplementowany standard.
Uruchom ten kod i sprawdź czy zadziała.

#include <string>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <array>

int main()
{
	// construction uses aggregate initialization
	std::array<int, 3> a1{ { 1, 2, 3 } }; // double-braces required in C++11 (not in C++14)
	std::array<int, 3> a2 = { 1, 2, 3 };  // never required after =
	std::array<std::string, 2> a3 = { std::string("a"), "b" };

	// container operations are supported
	std::sort(a1.begin(), a1.end());
	std::reverse_copy(a2.begin(), a2.end(),
		std::ostream_iterator<int>(std::cout, " "));

	std::cout << '\n';

	// ranged for loop is supported
	for (const auto& s : a3)
		std::cout << s << ' ';
}
0

Masz nowszy z miejsca, po co chcesz coś zmieniać?

0
spartanPAGE napisał(a):

Masz nowszy z miejsca, po co chcesz coś zmieniać?

Dlatego Niezdeklarowany identyfikator, Stephen Prata

0

Hmm, dziwne.
windows 10, vs community 2017, świeża instalacja (zarówno systemu jak i vs):
proof.png

0

Ponownie zainstalowałem Visual studio

carlosmay napisał(a):

Nie wiem czy możliwe jest wyłączenie. Zwykle kompilator zawiera najnowszy zaimplementowany standard.
Uruchom ten kod i sprawdź czy zadziała.

#include <string>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <array>

int main()
{
	// construction uses aggregate initialization
	std::array<int, 3> a1{ { 1, 2, 3 } }; // double-braces required in C++11 (not in C++14)
	std::array<int, 3> a2 = { 1, 2, 3 };  // never required after =
	std::array<std::string, 2> a3 = { std::string("a"), "b" };

	// container operations are supported
	std::sort(a1.begin(), a1.end());
	std::reverse_copy(a2.begin(), a2.end(),
		std::ostream_iterator<int>(std::cout, " "));

	std::cout << '\n';

	// ranged for loop is supported
	for (const auto& s : a3)
		std::cout << s << ' ';
}

Ten program uruchamia się na chwilkę i od razu znika, dostaję takie logi

'ConsoleApplication6.exe' (Win32): Loaded 'C:\Users\mikus\Documents\Visual Studio 2017\Projects\ConsoleApplication6\Debug\ConsoleApplication6.exe'. Symbols loaded.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\kernel32.dll'
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp140d.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\vcruntime140d.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ucrtbased.dll'
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ucrtbased.dll'
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ucrtbased.dll'
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ucrtbased.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'ConsoleApplication6.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
The thread 0x2718 has exited with code 0 (0x0).
The thread 0x34ec has exited with code 0 (0x0).
The program '[14808] ConsoleApplication6.exe' has exited with code 0 (0x0).

0

Wszystko spoko. Odpal swój program z poziomu terminala albo z poziomu VS przy pomocy kombinacji klawiszy ctrl + f5, żeby coś zobaczyć ;)

0

No to masz C++11. Teraz musisz poszukać informacji jak uruchomić program bez jego zamykania.
Dość staromodny (ale uniwersalny) sposób znajdziesz pod hasłem "C++ Press Enter to continue" (jest o tym nawet cała książka jakby ktoś się interesował SF).

1 użytkowników online, w tym zalogowanych: 0, gości: 1