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

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply Alex 5/5/2009 11:41:38 AM

See related articles to this posting


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
Reply Dennis 5/5/2009 11:36:42 PM
comp.sys.hp.hpux 4391 articles. 6 followers. Post

1 Replies
255 Views

Similar Articles

[PageSpeed] 27


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

program that compiles in C compiler but not in C++ compiler
Hi, I need a small program that compiles in C compiler but not in C++ compiler. Thx in advans, Karthik Balaguru KBG <karthik.balaguru@lntinfotech.com> wrote: > I need a small program that compiles in C compiler but not in C++ > compiler. No problem, just send $10 to paypal@zevv.nl and I'll do your homework for you. -- :wq ^X^Cy^K^X^C^C^C^C KBG said: > Hi, > > I need a small program that compiles in C compiler but not in C++ > compiler. Can you think of any syntactic differences between C and C++? For example, what about keywords? They are very, very sen...

How to compile C++ program with templates to pure C or C++ program without templates?
Hi, I heard that debug some C++ templates is very difficult. I'm wondering whether it is possible to compile C++ program with templates to pure C or C++ program without templates? Best wishes, Peng In article <1129128623.514540.179850@g14g2000cwa.googlegroups.com>, PengYu.UT@gmail.com <PengYu.UT@gmail.com> wrote: >I heard that debug some C++ templates is very difficult. I'm wondering >whether it is possible to compile C++ program with templates to pure C >or C++ program without templates? The point of using templates is to not do that, since, that's also d...

C vs. C++ and C compiler optimization question
/* Consider the following C snippet: */ Foo *pFoo = NULL; void FooLength(Foo *pFoo); void FooHello(Foo **ppFoo); void FooWorld(Foo **ppFoo); void FooLength(Foo *pFoo) { int count = 0; for (Foo *p = pFoo; *p; p++) ++count; return count; } void FooHello(Foo **ppFoo) { int count = FooLength(*ppFoo); // ... } void FooWorld(Foo **ppFoo) { int count = FooLength(*ppFoo); // ... } // Consider the following C++ snippet: class FooHelloWorld { public: void FooHello(Foo **ppFoo) { iCount = FooLength(*ppFoo); // ... } void FooWorld(Foo *...

Are sun studio C/C++ compilers and Forte C/C++ compilers same ??
Is there any difference between sun studio compilers and forte compilers??? or the names have been changed??? In article <1145338052.955429.256610@v46g2000cwv.googlegroups.com>, "ameya_agnihotri" <ameyaagnihotri22@gmail.com> writes: > Is there any difference between sun studio compilers and forte > compilers??? > or the names have been changed??? One of many name changes in the product's history (including amongst others, Java somethingortheother, Workshop, Proworks/Teamworks, and probably more I've forgotten). Of course, the versions and features cha...

Compiling a C program through another C program
As "spawnl" executes an exe through C code., similarly how can we compile a C program through another C program (on Windows platform) ? On Sep 28, 8:29 pm, Ajinkya <kaleajin...@gmail.com> wrote: > As "spawnl" executes an exe through C code., similarly how can we > compile a C program through another C program (on Windows platform) ? Command in unix platform will do too... On Sep 28, 10:29 pm, Ajinkya <kaleajin...@gmail.com> wrote: > As "spawnl" executes an exe through C code., similarly how can we > compile a C program through another ...

MPLAB C 30 Student Edition C-Compiler optimization level 1
Here is a quote from Microchip: "The MPLAB C30 C Compiler Student Edition is free! It is full-featured for the first 60 days. After 60 days only optimization level 1 can be enabled in the compiler. The compiler will continue to function after 60 days, but code size may increase." Does anyone really know what 'optimation level 1' really means? Or is this a trick get you purchase the the full blown version? Has anyone seen a difference after the 60 days? Thanks, Thomas Magma "Thomas Magma" <somewhere@overtherainbow.com> wrote in message news:A7G7i...

System call utssys OR Getting info of processor family within C/C+
Hi, HP-UX B.11.23 U ia64 I would like to get info of processor family ("Intel(R) Itanium 2 9000 series") within C/C+ (?) > tusc machinfo [---omitted---] sysinfo(_SI_MACHINE_MODEL, "ia64 hp server rx4640", 64) .................................................... = 22 sysinfo(_SI_MACHINE_IDENT, "43eae323-6165-11db-8e9b-5b7bebc1ff81", 64) ..................................... = 37 sysinfo(_SI_MACHINE_SERIAL, "USE463828J", 64) .............................................................. = 11 utssys(0x7fff5f50, 0, 8) ...................................

Writing a C/C++ compiler in C++
I've been thinking of writing a C++ compiler in C++ over the next several years, and I was wondering what's changed in writing a compiler? I've been pouring over these groups and there seems to be a lot of tools for starting but is the modern process still the same? As far as I understand it you write a lexer that tokenizes all the symbols, then write a parser that parses all of the tokens, then walks the parse tree to generate the asm or IL that gets shoved to the backend. So it seemed straightforward except that C++ isn't a LALR(1) grammer that Bison or Byacc accepts. Does ...

Better C/C++ Than C/C++?
I am looking for a good systems programming language that can be used instead of C/C++. My qualifications for the language are: * mature compiler(s) that produce native-code binaries (for Windows) * open source - preferable, but not 100% necessary Thanks, Kevin "Kevin Albrecht" <kevin@albrecht.net> writes: > I am looking for a good systems programming language > that can be used instead of C/C++. My qualifications > for the language are: > > * mature compiler(s) that produce native-code > binaries (for Windows) Ocaml, D, cyclone, Eiffel, Beta >...

HPGCC calling another c program from within a c program
Haven't seen a solution to calling another c program from within a c program, as one's routines migrate beyond 82kb limit would like to use c only instead of hybrid mix of sysRPL. Has anybody cracked it yet? ........ Off at a tangent, just recently been messing around with win_text, if anybody interested, added some more functionality to win_text_new.c, ie numerics only higlighted text box, a callback routine to validate your data. ...

jython and C-c C-c
How do I get C-c C-c to work with jython? I have the jpython command set to jython, and I can start the interpreter with C-C ! and then use C-c C-c, but this is rather frustrating. If I try to use C-c C-c without first starting the interpreter in another window I get wrong type argument: sequencep, jpython Thanks, Dave Cook ...

renice from within C/C++ program
Is it possible to do this within a program without using system()? I have an app that I want to renice only during a certain portion of code. I would assume calling system() wont speed me up unless the amount of time I would spend during this portion of code is quite long. Is there a C-style interface for renice? Can a program renice itself? Thanks, Jeff On 28 Nov 2006 18:28:05 -0800, Jeff <jeep@rahul.net> wrote: > Is it possible to do this within a program without using system()? > > I have an app that I want to renice only during a certain portion of > code. I would ...

Compiling MIPSpro C program using MIPSpro C++ compiler on SGI system
Hello, Can I run the subject line program using CC instead of cc? I attempted to use the "-c" option and it told me things were undefined. Isn't this CC option the same as the cc -c option? Thank you, Christopher Lusardi Christopher M. Lusardi wrote: > Can I run the subject line program using CC instead of cc? I attempted > to use the "-c" option and it told me things were undefined. Isn't this > CC option the same as the cc -c option? No. In general, the meanings of flags depend on your compiler; neither "cc" nor &quo...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306657604)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306657604) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Workshop. Please...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306932415)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306932415) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Workshop. Please...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45307232407)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45307232407) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Workshop. Please...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306646348)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306646348) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Worksh...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306657604)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306657604) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Worksh...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306932415)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306932415) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Worksh...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306957605)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306957605) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Worksh...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45307232407)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45307232407) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Worksh...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306957605)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306957605) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Worksh...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45307257608)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45307257608) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Worksh...

US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306932415)
US-MA-Natick: Developer, C/C++, System level programming/realtime systems; C-P (45306932415) ============================================================================================ Position: Developer Reference: SMC01484 Location: Natick MA Duration: C-P Skills: 5+yrs strong algorithmic programming with C/C++ and an appreciation for engineering applications (such as controls, signal processing, applied math, etc.). Exp with, system_level programming, real_time systems, Simulink, and Real_Time Worksh...