This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

optimization with #pragma or using the option window

Hello,
I'm trying to optimize my code in time so I used the option window-->C/C++/ selected optimization level 3(-O3) and checked optimize for time. I'm using usb HID in the same project and unfortunately the usb device is not recognized any more.
But when I put

#pragma O3
#pragma Otime

before each function in this file, the usb is recognized and there are no problems. So I just want to know if there is a difference between optimizing using the option window in keil or using #pragma.

Parents
  • Well, #pragma will not matter until after that #pragma line.

    Command-line switches on the other hand is active before even first source line is processed.

    So if it makes a difference with #pragma instead of specifying -O3 for just the file, then you have some part of the file that is compiled differently before you even reach your #pragma.

    And if you use -O3 globally for the project, then it obviously affects the full project and not just code inside a specific source file.

Reply
  • Well, #pragma will not matter until after that #pragma line.

    Command-line switches on the other hand is active before even first source line is processed.

    So if it makes a difference with #pragma instead of specifying -O3 for just the file, then you have some part of the file that is compiled differently before you even reach your #pragma.

    And if you use -O3 globally for the project, then it obviously affects the full project and not just code inside a specific source file.

Children