Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am using Visual Studio 2012 to write C++ project. I was trying to use O2 or Ox optimization when building the project. But it prompted up an error that " cl: command line error D8016:'/Ox' and '/RTC' command-line options are incompatible."

I tried to find the solution from the internet, but it didn't work for me.

Hope some one could give me a hand.

Best

like image 636
DreamOn Avatar asked Apr 20 '14 06:04

DreamOn


1 Answers

First things first, your error code is wrong. You probably made a mistake when posting it as it should be D8016, not D0816. Hopefully, you have not done other mistakes that could mislead us...

Other than that, the error message is clear:

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

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

Command-Line Error D8016

The short answer - as the error says -, you cannot use both of them simultaneously. The life is full of compromise, you will need to select either of them whichever is more important for you.

The solution is to turn off /RTC for the release build, and only use it for the debug builds to find issues. See the corresponding documentation, that is also available from the first link above, for more details:

Run-time error checks are a way for you to find problems in your running code; for more information, see How to: Use Native Run-Time Checks.

If you compile your program at the command line using any of the /RTC compiler options, any pragma optimize instructions in your code will silently fail. This is because run-time error checks are not valid in a release (optimized) build.

You should use /RTC for development builds; /RTC should not be used for a retail build. /RTC cannot be used with compiler optimizations (/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 an /Od build).

like image 155
lpapp Avatar answered Sep 20 '22 23:09

lpapp