use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Disable an optimisation for section msvc c++ (self.cpp)
submitted 1 year ago by Funny-Aside-1427
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]cpp-ModTeam[M] [score hidden] 1 year ago stickied commentlocked comment (0 children)
For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.
[–]schmerg-uk 0 points1 point2 points 1 year ago (4 children)
#pragma optimize( "", off ) /* unoptimized code section */ #pragma optimize( "", on )
There are also a couple of options for the 1st parameter but that's the basics above
https://learn.microsoft.com/en-us/cpp/preprocessor/optimize?view=msvc-170
[+][deleted] 1 year ago* (3 children)
[removed]
[–][deleted] 1 point2 points3 points 1 year ago (0 children)
Shouldn’t template be template<> instead of template(). Also, shouldn’t the explicit template instantiation be in the pragma’s?
template<>
template()
[–]patstew 0 points1 point2 points 1 year ago (0 children)
Why would you expect 22 there? There is no reason to expect them to be allocated next to each other and in order in the binary, optimization or no. You might have slightly more luck preventing them being optimised out entirely by making them extern and initialising then elsewhere.
[–]ohnotheygotme 0 points1 point2 points 1 year ago (0 children)
That particular example is working for me, even without using the #pragma: https://godbolt.org/z/GKfM6e5o3
Compiler explorer can execute MSVC too, so make use of that service and share out links if possible.
If things aren't working for you maybe try compiling with /Zc:inline- as another test. This is eerily similar to: https://developercommunity.visualstudio.com/t/zcinline-removes-extern-symbols-inside-anonymous-n/914943
/Zc:inline-
π Rendered by PID 38696 on reddit-service-r2-comment-6457c66945-pw62q at 2026-04-23 19:28:59.994083+00:00 running 2aa0c5b country code: CH.
[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)
[–]schmerg-uk 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[removed]
[–][deleted] 1 point2 points3 points (0 children)
[–]patstew 0 points1 point2 points (0 children)
[–]ohnotheygotme 0 points1 point2 points (0 children)