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.

Adding pragma results in wrong debug information.



Hi, all
       Recently, I added pragma in my code to gain better performance. In the debug version
I found in the watch windows some local variables disappeared. If I commented out the
pragma statements, everything is right. Is there any connection between them? Why? Thanks.

Best Regards
Jogging

  • Hi,

    Pragma is used to define certain options which cannot be defined using standard C syntax/functions.

    One of the functions of pragma includes over-riding compiler defined parameters, for eg. a memory map, etc.

    If you assign a section of memory, explicitly using pragma, and if that section of memory is already being used by the compiler for storing certain local variables, then "pragma" overrides those assignments.

    As a result your local variables which maybe assigned a memory say A during execution, and if the memory section defined by pragma overlaps with this memory, then pragma will have higher priority which will cuase your local variables to disappear.

    To overcome this, you will have to ensure that your pragma defined memory is not overlapping with any of your local variable memory .

    Hope this helps,

    Regards,

    Sid

  • Thanks, Sidharth
             Actually the pragma I used is about loop count. Maybe this changes the stack layout.
    Although some local variables become invisible, the program runs correctly.


    Best Regards
    Jogging Song

  • Hi,

    It is certainly possible that your program runs correctly, if the local variables which are being replaced are not of as much importance so as to affect the program execution in a drastic manner.

    But, I would suggest., a good practice would be to explicitly define your memory maps in a distinct manner, so that they dont overlap. This may help in other applications.

    Regards,

    Sid