[aCC] Getting info of optimization level within compiled C/C++ program

Hi,

HP-UX B.11.23 U ia64
aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]

I would like to get info of optimization level within compiled C/C++
program.


Something like (using preprocessing directives)
int foo()
{

#ifdef <something-0>
 return 0;  // optimization level == 0
#endif

#ifdef <something-1>
 return 1;  // optimization level == 1
#endif

  ...

}



Here are results of simple experiment.

--- empty.cpp ---
int main()
{
    return 0;
}
-----------------


$ aCC -E -dM empty.cpp > ! pdm0
$ aCC -E -dM +O1 empty.cpp > ! pdm1
$ aCC -E -dM +O2 empty.cpp > ! pdm2
$ aCC -E -dM +O3 empty.cpp > ! pdm3
$ aCC -E -dM +O4 empty.cpp > ! pdm4

$ diff pdm0 pdm1

$ diff pdm0 pdm2
25a26
> #define __BUILTIN_MILLI 1

$ diff pdm0 pdm3
25a26
> #define __BUILTIN_MILLI 1

$ diff pdm0 pdm4
25a26
> #define __BUILTIN_MILLI 1


So, it seems that the only macros we can use is __BUILTIN_MILLI.

However, can __BUILTIN_MILLI be defined while optimization level < 2?
If it is true, it means that we can't use __BUILTIN_MILLI to detect
optimization level.

Is there other way to get info of optimization level within compiled C/
C++ program?

Thanks.

Alex Vinokur

0
Alex
5/5/2009 11:41:38 AM
comp.sys.hp.hpux 4398 articles. 6 followers. dewi.bening (7) is leader. Post Follow

1 Replies
292 Views

Similar Articles

[PageSpeed] 9
Alex Vinokur wrote:
> I would like to get info of optimization level within compiled C/C++
> program.

There aren't any defines.  You could pass in an extra one when you add +O2.

> it seems that the only macros we can use is __BUILTIN_MILLI.

You aren't allowed to look at the define.  In fact it is useless and may 
be removed.

> Is there other way to get info of optimization level within compiled C/
> C++ program?

No, other than pass some define you invent.
0
Dennis
5/5/2009 11:36:42 PM
Reply:
Similar Artilces:

Ping::: Big Steel.. Verizon Info.
Hey, thought this might be interesting for you: http://androidforums.com/motorola-droid-razr-razr-maxx/579226-my-verizon-data-widget-no-longer-supported.html FWIW *MY* widget will NOT work over 3G/4G.. Only on a network connection... This just started. On 7/9/2012 5:19 PM, Foster wrote: > Hey, thought this might be interesting for you: > > http://androidforums.com/motorola-droid-razr-razr-maxx/579226-my-verizon-data-widget-no-longer-supported.html > > FWIW *MY* widget will NOT work over 3G/4G.. Only on a network > connection... This just started. I was on t...

i forget password to acces blockdiagram, how can i acces it?
I am using LabVIEW 6.1 version. I enable password protect to acces the block diagram. But i forget the password. Now how can i acces block diagram? You can't - that's the point of having a password protection. You could always try traditional crack3r methods, like a brute force script. See: http://digital.ni.com/public.nsf/websearch/BC99793C48857A41862565BC006F472C?OpenDocument ...

doubt in basic c++ code
hi, i just started learning c++, and i tried this sample program. i expected output to be 20 and 20 but i got 10 and 20. 'i' has not changed, but the address of i and value of ptr are same. can some one please clarify. #include <iostream> using namespace std; int main() { const int i = 10; int* ptr = const_cast<int*>(&i); *ptr = 20; cout << "i: " << i << endl; cout << "ptr: " << *ptr << endl; return 0; } TIA fin. fintracker@gmail.com wrote: > hi, > > i just started learning c++, ...

Optimal indexing of database costs only 2.33 bits/element (linear not n log(n) )
We would think that the amount of information required to distinguish eleme= nts by some unique identifiers grows with n log(n) ... but it turns out tha= t it can be compressed using linearly growing amount of information. The tr= ick is that we don't need the information about the order of these identifi= ers, saving log(n!)~ nlog(n) bits of information. Specifically, to encode minimal prefix tree required to distinguish hash va= lues of elements, there is asymptotically required 2.77 bits/elements and i= t can further reduced to 2.33 bits/element: http://arxiv.org/abs/1206.4555 ...

The compiled application cannot find my file?
Hello I have made a simple function as shown below in R2006b function binary = rgb2binary(rgbpath) rgb = imread(rgbpath); gray = rgb2gray(rgb); binary = im2bw(gray); imshow(binary); Now I have successfully compiled the above function using mcc -m rgb2binary.m Now when I open command prompt and enter rgb2binary('e:\angio3.bmp') I get the following error message. ??? Error using ==> imread File "('e:\angio3.bmp')" does not exist. Error in ==> rgb2binary at 2 I tried to open a different image file too, but doesnt work. Where am I going wrong. The abov...

popen4
In bash I do the following: linus:journal tim$ /home/AKMLS/cgi-bin/perl/processJournal-Photo.pl hiccup -bash: /home/AKMLS/cgi-bin/perl/processJournal-Photo.pl: No such file or directory linus:journal tim$ echo $? 127 In python, use os.popen4 I do the following: >>> fin,fout = os.popen4('/home/AKMLS/cgi-bin/perl/processJournal-Photo.pl hiccup;echo $?') >>> results = fout.readlines() >>> results ['/bin/sh: /home/AKMLS/cgi-bin/perl/processJournal-Photo.pl: No such file or directory\n', '127\n'] Well, I got the exit code as the last ...

How to get the parameters of the equations using lsqnonlin??
Dears: I would like to ask for help about parameters estimation from the equations below: There are five parameters in total: omega beta alpha gamma lambda Z(t)=(R(t)-lambda*H(t))/sqrt(H(t)) H(t)=omega+beta*H(t-1)+alpha*(Z(t-1)-gamma*sqrt(H(t-1)))^2 Obj. eq. lik=-0.5*(ln(H(t))+Z(t)^2) Is it possible to do this using lsqnonlin?? Thanks in advance!! ...

[Commercial] Linux System and Device Driver Programming from Professionals #2
Hello All, Linux System and Device Driver Programming training is one of flagship training solutions offered by Concepts Systems. This training has become special one due to Concepts faculties having experience in File Systems, Storage and Embedded Space. Course Highlights: Linux System Programming: -Operating Systems Basics -System Calls for I/O -Multithreading and Synchronization -Interprocess communication -Memory Management -Memory mapped files -UNIX/ POSIX files and File Systems -Pipes Detail syllabus is available at http://www.conceptssys.com/SyllabusPdf/LinuxSysPro.pdf Linux Kerne...

Error 114 in Microfocus Server Express 2.2 when calling C functions
I am running a server express 2.2 run-time on a HPUX 11 O/S. COBOL programs are linked with C functions, and in particular with OCI Oracle C functions. I have execution problem when executing some of the C functions : << error code: 114 Attempt to access item beyond bounds of memory (Signal 11) >> It seems that IF statements with null pointer in the C programs are the cause of this stop. However, previous versions of Microfocus compilers were compliant with this syntax. Do you know a run-time option or a compiler option to prevent this error ? Microfocus support is n...

Where can I get help with GPS?
GPL edition 4.4.1, that is. My problem is that on two separate laptops (an HP and a Toshiba) the mousepad scroll function does not work (and it does work with every other program, naturally). I'm hoping that this is just some configuration switch, but I haven't found any info so I'm wondering where I might seek some help on this, because GPS is near useless without easy scrolling. Thanks. On Wed, 2 Mar 2011 19:09:37 -0800 (PST), KK6GM wrote: > GPL edition 4.4.1, that is. My problem is that on two separate > laptops (an HP and a Toshiba) the mousepad scroll functio...

Acc 2k Can't delete record after conversion from Acc97
Hello, I have a split database which has been running under v8 for several years, after conversion to v9 a button created by a wizard suddenly won't delete records. The form's record source is a query based on three tables. The record appears to be deleted, the confirmation message appears, but when the form is reopened, the record miraculously reappears. When I change the record source to a single table and do a delete then it works. There are no problems with the other dozen or so forms in the front end, they use multiple tables as a record source. So far I have: -copied the controls...

why i can't get the value out of each block?
a=[1,2,0,10] a.each.with_index{|item,idx| begin puts 10/item rescue print "it is my wrong ",item,idx,"\n" x=item end} puts "x=",x the output is :NameError: undefined local variable or method `x' for main:Object why i can't get the value out of each block? -- Posted via http://www.ruby-forum.com/. Hi In that case, x has scope of inside block. if you want to reffer x out of blok, sould initialize before block. like berow. a=3D[1,2,0,10] x=3Dnil a.each_with_index {|item, idx| begin puts 10 / item rescue print "...

malloc family in C++
In comp.lang.c in a discussion drifting off topic there I wrote: > No rule without exceptions... > Last week I used malloc in C++ for the first time in the 15 years I've > been playing with the language... I had a buffer which I needed to > shrink every once in a while, so I saved lots of CPU cycles switching > from new[] and delete[] to malloc, realloc and free. Someone replied, suggesting using vector<>::resize(). But resize just calls erase which causes destructors of contained objects to be called, but it does not release any memory held by the vector. My contai...

C spot run: initializing variables
I've got this bit of code, and I can't really explain to myself why it does what it does.... int func1() { static int r=0; return(++r); } int func2() { static int r; r = 0; return(++r); } int main() { printf("%d,%d,%d\n", func1(), func1(), func1()); printf("%d,%d,%d\n", func2(), func2(), func2()); exit(0); } I imagined it would print 1,1,1 1,1,1 but after compiling and running, it prints 3,2,1 1,1,1 In func1, are the static r and the returned r not the same var? what's what? Even it the returned r is a global, why...

get https page
What I'm trying to do seems like it should be really easy. I want to use python to grab the page https://www.schedulesource.com/teamwork/logon/ I'm using active state python 2.3.2 on windows. I've tried putting in various libraries, running various code sippets, but I always get the following message: raise URLError('unknown url type: %s' % type) I'm sure this is really easy, can anybody point me in the write direction? Thank you. Ben >>> import urllib >>> r = urllib.urlopen("https://www.schedulesource.com/teamwork/logon/") >>&g...

Java Threads
Hy there, I'm building an application that creates a thread. This thread creates other threads to perform several tasks. My question is simple. Being this main thread created in a JSP page, and still running after the user logs out, how can i get the current status of the thread? I would like for the user, when he logs on the application, to verify if the thread is active, that is, the current status. I can't seem to be able to get the thread once it is initialized. Thanks in advance for any help. Regards Pedro Pinto On Apr 8, 2:42 am, Pedro Pinto <kubi...@gmail.com> wrote...

I could not get this const before a function declaration
I understand that a const qualifier after the function declaration makes it a const function for the class. Like int func1 const ( double, long int ); Now what is the purpose of the following const int func1 const ( double, long int ); What is the purpose of the const before the declaration -Parag <parag_paul@hotmail.com> wrote in message news:f0b0cb86-c621-4b58-9eb5-0f01e501b729@i18g2000prn.googlegroups.com... >I understand that a const qualifier after the function declaration > makes it a const function for the class. > > Like > > int func1 const ( double, lo...

texture names
hi all, i have the following log when running my application: created tex 2/3 in maketextures() context 65536 created tex 4/5 in maketextures() context 65536 created tex 1 in patch context 65536 created tex 2 in patch context 65536 created tex 3 in patch context 65536 created tex 4/5 in maketextures() context 65536 -> although it is definitely the same context, i get the texture names 2,3 twice. the specs say: "Texture names returned by glGenTextures are not returned by subsequent calls to glGenTextures unless they are first deleted by calling glDeleteTextures" but there a...

Spawning matlab from within matlab
Hello all, I would like to spawn multiple matlab processes from an '.m' script. Meaning, run an m-file from a 'parent' Matlab that launches, say, 8 more 'children' matlab processes. I'd like to do it in such a way that the same m-file in the 'parent' is able to close down, or kill, all the 'children' processes. Any suggestions? Joe ...

WebSphere/MS Acces
I'm learning Websphere and I would like to define a new connection on a MS Access database. Do you know how to configure this kind of connection : - Do I need a zip or jap file that contains the JDBC-ODBC pilote ? - WebSphere ask me to choose between DB2 Universal database Vx.x, Oracle, MySQL, SQL92,SQL99 ... Can you help me to make the right choice ? Thanks a lot ! ...

Easily create Excel BOM from top level assembly
Hello all- I have recently authored a program to easily make a hierarchical or flattened Excel BOM from a top level SW assembly. It's easy to capture ALL the parts in your assembly with OKSWTree. No more opening each individual assembly drawings and clicking file->save as. Let OKSWTree do the drilling down for all the parts for you. Imagine within seconds having a complete BOM in Excel that gives you the ability to cost, plan, describe and implement your project to the rest of the organization. Try the beta version at oksoftcorp.com. Regards Doogie ...

What is the meaning of this warning, and how do I get rid of it?
I have a portion of code along the following lines: volatile unsigned char x ; unsigned int f(unsigned char *y) ; When I do unsigned int z = f(&x) ; the compiler issues the following warning: warning: passing arg 1 of `f' discards qualifiers from pointer target type What does this exactly mean? How do I change my code so that the compiler is happy about it? James H. Newman wrote: > I have a portion of code along the following > lines: > > volatile unsigned char x ; &g...

newbie struggling to get help with certain commands
Why is it that when i do a 'help index', certain commands are not listed? like 'create', 'commit'. And these commands are not in the oracle tutorials either, see http://www.oracle.com/technology/docs/tech/sql_plus/index.html . Are these commands different from the others? On Feb 14, 1:17 am, sean nakasone <seannakas...@yahoo.com> wrote: > Why is it that when i do a 'help index', certain commands are not listed? > like 'create', 'commit'. And these commands are not in the oracle > tutorials either, seehttp://www....

Eiffel, C++ and the Diamond Problem
I started looking into Eiffel in order to see if there was a better way of doing OO programming. One of the attractions of Eiffel is the claim that Eiffel does multiple inheritance safely. Before Eiffel, the object oriented languages either avoided multiple inheritance entirely (e.g. Java), or implemented it in an unsafe and confusing manner (C++ comes to mind). One of the issues raised by multiple inheritance is the diamond problem. Assume that we create a class JOIN that inherits classes A and B. Further assume that the classes A and B both inherit from the class BASE, e.g. ...

Re: help with SAS programming #3 659373
antoniababe@YAHOO.SE wrote: >I have a dataset like > >Obs Animal week Group Weight R > >1 1 1 1 28.4 1 >2 1 2 1 28.6 1 >3 1 3 1 28.7 1 >4 1 4 1 29.7 1 >5 1 5 1 29.9 1 >6 1 6 1 30.1 1 >7 1 7 1 30.9 1 > > >. . >. . > >33508 550 13 1 28.1 1 >33509 550 14 1 28.0 1 &...