[chbot] Chchrobotics Digest, Vol 153, Issue 31

Charles Manning cdhmanning at gmail.com
Tue Jun 30 22:57:10 BST 2020


I do understand the purpose of optimisation. Thanks.

If you read the original posting you will see why.

All I want to do is printf the level so I have that in the logs.

With a Makefile built system it is reasonably easy by passing in a string
with -D, but is a pain with an Eclipse managed system (as I am working with
at the moment).

Something along the lines of:

OPT_LEVEL = -Os

gcc -c $(OPT_LEVEL) -DOPT_LEVEL_STRING="$(OPT_LEVEL)"

and in the C file

const char *opt_string=OPT_LEVEL_STRING;




On Wed, Jul 1, 2020 at 9:34 AM Bevin Brett <bevin_brett at hotmail.com> wrote:

> I am interested in why your code cares about optimization level.
>
> Most modern compilers have many different optimizations controlled by
> command line switches, and they also package them into a few sets for easy
> usage
>
> They can be summarized as:
>
> optimizations that have leave a very close source to instruction set and
> data placement correspondence,  for ease of debugging
>   these are always all on by default
>
> safe optimizations that shrink the instructions size
>
> safe optimizations that expand the instructions size and usually decrease
> execution
>
> unsafe optimizations like the above - these may cause crashes or bad
> answers unless your program meets some additional requirements
>
> /Bevin
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20200701/0148ac9a/attachment.html>


More information about the Chchrobotics mailing list