This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Excluding code from optimization

Genius 5910 points

I found the source of the problem. The optimizer removed large parts of my program. I debug in optimization level 0 and run the program in level 2. Because interrupt timing issues.  So it took me almost a week to find it. Compiler issues sucks.

I got a lot of complex pointer references. That the compiler removes.

I made everything volatile. But that doesn't work for pointers and get a lot of the following errors: Description    #169 argument of type "volatile unsigned char *" is incompatible with parameter of type "unsigned char *"   

-  Is there a optimization report.  So I know what is removed.

- Can I exclude pointers from optimization.

-  Can I exclude parts of the code from optimization.

 Suggestions?

Thanks,

 Ernst

  • Which target CPU are you using?  What compiler version?  Please show the exact build options used.

    evs said:
    I got a lot of complex pointer references. That the compiler removes.

    Please post the source to one function, preprocessed like this, that has this problem.  Clearly show how you know the compiler has removed code which should remain.

    Thanks and regards,

    -George

  • As George suggests, we'll need a test case to analyze this issue, but I may have a refinement to your "volatile" technique.  If you want to make the pointer itself volatile, declare it like so:

    unsigned char * volatile ptr1; /* ptr1 is volatile */

    instead of:

    volatile unsigned char *ptr2; /* ptr2 points at something that is volatile */