|
Home > Archive > Unix Programming > January 2005 > Disable optimization within code
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Disable optimization within code
|
|
| John Smith 2005-01-27, 2:51 am |
| I have a fairly complex build with lots of makefiles. One C++ file is
auto-generated and included into this build into many applications which
uses it. Basicly I need to compile it with -O0 when all other files are
compiled with -O2.
In Microsoft C++ compiler it's quite easy to turn off the optimization for
this particular file with a #pragma:
#ifdef _MSC_VER
#pragma optimize("", off)
#endif
void FuncA()
{
...
}
#ifdef _MSC_VER
#pragma optimize("", on)
#endif
Is there a similar thing you can do with gcc/g++?
Thanks in advance.
-- John
| |
| Andrei Voropaev 2005-01-27, 2:51 am |
| On 2005-01-27, John Smith <john.smith@x-formation.com> wrote:
> I have a fairly complex build with lots of makefiles. One C++ file is
> auto-generated and included into this build into many applications which
> uses it. Basicly I need to compile it with -O0 when all other files are
> compiled with -O2.
>
> In Microsoft C++ compiler it's quite easy to turn off the optimization for
> this particular file with a #pragma:
>
> #ifdef _MSC_VER
> #pragma optimize("", off)
> #endif
>
> void FuncA()
> {
>
> ..
> }
>
> #ifdef _MSC_VER
> #pragma optimize("", on)
> #endif
>
> Is there a similar thing you can do with gcc/g++?
Have you considered manipulating make files and not the source file?
After all make if fairly flexible to implement things like that (check
for example target specific variables).
--
Minds, like parachutes, function best when open
| |
| John Smith 2005-01-27, 5:52 pm |
| > Have you considered manipulating make files and not the source file?
> After all make if fairly flexible to implement things like that (check
> for example target specific variables).
Yes I have considered it and know it's the only way out, if nothing better
comes up. I already know about target specific variables.
However my build is special. The *.cpp file in mind is included through
another cpp file like this:
#include "foo.cpp"
So if I disable optimization it affects a lot more then just the code I
want.
The only way to solve this is to restructure the build process to become
more "standard". However theres many good reasons for the way it's done with
including code into other files and restructuring it, will only cause new
problems.
-- John
|
|
|
|
|