Visual Studio: D8016 command line error: '/ Ox' and '/ RTC' command line options are incompatible

I am using Visual Studio 2012 to write a project in C ++. I tried to use O2 or Ox optimization when creating a project. But this caused an error that "cl: D8016 command line error: '/ Ox' and '/ RTC' command line options are incompatible."

I tried to find a solution from the Internet, but it did not work for me.

Hope someone can give me a hand.

The best

+6
source share
2 answers

First of all, your error code is incorrect. You probably made a mistake when publishing, as it should be D8016, not D0816. I hope you did not make other mistakes that could mislead us ...

Other than that, the error message is clear:

Visual Studio: D0816 command line error: '/ Ox' and '/ RTC' command line options are incompatible

But you can also see a description of this type of error here:

Command line error D8016

The short answer is - as the error says - you cannot use both of them at the same time. Life is full of compromises, you will need to choose any of them, which is more important for you.

The solution is to disable /RTC to build the release and use it only to build debugging to find problems. See the related documentation , which is also available at the first link above, for more details:

Checking run-time errors is a way to find problems in your working code; See the Practical Guide for more information. Using custom runtime checks.

If you compile your program on the command line using any / RTC compiler options, any pragma optimization instructions in your code will fail silently. This is because runtime checks are not valid in the (optimized) version.

You must use / RTC for development; / RTC should not be used for retail assembly. / RTC cannot be used with compiler optimization (/ O Options (Optimize code)). A program image built with / RTC will be slightly larger and slightly slower than an image built with / Od (up to 5 percent slower than the / Od build).

+4
source

In the MSDN documentation : you cannot use /RTC with the /O options (optimize code) .

If you want to use optimization, disable the /RTC flag (or disable the optimization of your timeout checks).

Or, to avoid all this, create separate layout configurations that require separate flags (for example, debug and release builds).

+3
source

All Articles