Disable optimization within code
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Disable optimization within code




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Disable optimization within code  
John Smith


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-05 07: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







[ Post a follow-up to this message ]



    Re: Disable optimization within code  
Andrei Voropaev


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-05 07: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





[ Post a follow-up to this message ]



    Re: Disable optimization within code  
John Smith


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-27-05 10: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







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:11 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register