www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/24/09:02:58

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Alex Vinokur <alexvn AT bigfoot DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: What does a program know of its optimization level?
Date: Sun, 24 Feb 2002 15:46:43 +0200
Lines: 61
Message-ID: <3C78EEC3.EA2DFB88@bigfoot.com>
NNTP-Posting-Host: 62.90.123.5
Mime-Version: 1.0
X-Trace: fu-berlin.de 1014558406 6337751 62.90.123.5 (16 [79865])
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

===============================================================
Windows98
gpp : GNU C++ version 2.95.3 20010315/djgpp (release) (djgpp)
      compiled by GNU C version 2.95.3 20010315/djgpp (release).
===============================================================

Here is some program.

// ----- C++-code : BEGIN -----

// File aaa.c

#include <iostream>

int main()
{
#ifdef __OPTIMIZE__
  cout << "Optimize = <" << __OPTIMIZE__ << ">" << endl;
#else
  cout << "Optimize = Not Defined" << endl;
#endif

  return 0;
}

// ----- C++-code : END -------



// ----- Compiling & Running : BEGIN -----
%gpp aaa.c
a.exe
Optimize = Not Defined

%gpp -O1 aaa.c
a.exe
Optimize = <1>

%gpp -O2 aaa.c
a.exe
Optimize = <1>

// ----- Compiling & Running : END -------


The program "knows" if it was compiled with optimization,
  however it doesn't know which level of optimization (O1, O2) was used.

Is there any possibility to know within a program
  which level of optimization was used?


  ===========================
  Alex Vinokur
    mailto:alexvn AT bigfoot DOT com
    mailto:alexvnw AT yahoo DOT com
    http://up.to/alexvn
    http://go.to/alexv_math
  ===========================


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019