Suppressing integral promotion in the Crossware 8051 C Compiler

by Crossware 22. February 2012 09:09

We have recently been asked how to put the /Op option on the command line of the Crossware 8051 C Compiler when building from within the Embedded Development Studio IDE.

We do not recommend that the /Op option is applied from the command line.  It can lead to unpredictable results and applying it across a whole module or a whole project can potentially lead to hard to track down faults.

Instead we recommend that it is applied to specific functions using the optimize pragma.

Here is the html version manual page for the /Op option:

At the bottom of that page is a link to the page for the optimize pragma:

So you would do something like this:

unsigned char a, b, c, d;

#pragma optimize("p", on)

    a = (b + c) / d;

#pragma optimize( "", on )

In this example, only the expressions in the function func() will have integral promotion suppressed.

Nevertheless, it is possible to apply command line options that are not specifically supported by the IDE by using the CCommandLine entry in a target.ini file.  See this page:



About this blog

This is where you will find topical information that we think might be useful to you.

Month List