[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 4387 articles. 6 followers. Post

1 Replies
226 Views

Similar Articles

[PageSpeed] 10


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

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) ...................................

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...

RE: LabVIEW with compiled C programs within the Hardware chips.
Hii All:smileyhappy:, &nbsp; I have a prgram in which LabVIEW is doing some measurement by reading C compiled program, which is already downloaded within the chip.Can anyone give me the exact interpretation of the program ,that how LabVIEW reading those compiled files from chips and performing pre determined measurements. &nbsp; &nbsp; Thanks and Regards Puneet Kapoor:manhappy: &nbsp; Dear Sir, First of all, i am very thankful to you for your reply. In this program i have a board with Microprocessor chip,&nbsp; Using LabVIEW we have to perform some measurement test for the...

Getting file size within C program using file descriptor
One can get file size within C program using file pointer and functions fseek and ftell. It it possible to get file size within C program using file descriptor (and perhaps function lseek and something else)? -- Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn "Alex Vinokur" <alexvn@big-foot.com> writes: > It it possible to get file size within C program using file > descriptor (and perhaps function lseek and something else)? "man fstat" Cheers, --...

Error when running executable compiled using Matlab within C++ program
I'm having some weird issues getting a compiled Matlab program to work. My research partner made a Matlab program a long time ago that he compiled into a Windows executable. It runs perfectly fine if he runs it from the command prompt. However, he needs to be able to run this program from within a C++ program. So basically, he's be using system("myprog.exe <inputs>"); in his C++ program to get it to run. However, when he does this, he gets the following error: Severe: MATLAB:118n:MissingICUData - ICU data not found So, I tried running it on my computer. I installed...

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 *...

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 ...

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. ...

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...

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...