Gmane
From: Alex Vinokur <alexvn <at> connect.to>
Subject: [Source] Simple C/C++ Perfometer : Copying char[] to vector (Version CS-1.0)
Newsgroups: gmane.comp.lang.c++.perfometer
Date: 2004-07-14 12:19:23 GMT (4 years, 50 weeks, 6 days, 7 hours and 10 minutes ago)
// =====================================
// C/C++ Program Performance Measurement
// -------------------------------------
// Simple C/C++ Perfometer : Exception Handling
// Version CS-1.0
// -------------------------------------
// FILE : info.cpp
// -------------------------------------
// Copyright (C) 2002-2004 Alex Vinokur
// mailto:alexvn <at> connect.to
// http://up.to/alexv
// =====================================

// ==============
#include "copystr.h"

// --------------------------------------
string get_compiler_info()
{
ostringstream oss;
ostringstream tss;
string str;

// ------ GNU gcc ------
#ifdef __GNUC__
  oss.str("");
  tss.str("");
  str.erase();

  oss << "GNU gcc " << __GNUC__;
#ifdef __GNUC_MINOR__
  oss << "." << __GNUC_MINOR__;
#ifdef __GNUC_PATCHLEVEL__
#if (__GNUC_PATCHLEVEL__)
  oss << "." << __GNUC_PATCHLEVEL__;
#endif
#endif
#endif

#if (__CYGWIN32__ || __CYGWIN__)
  oss << " (CYGWIN)";
#endif

#if (__MINGW32__ || __MINGW__ )
  oss << " (MINGW)";
#endif

#if (__DJGPP__)
  oss << " (DGGPP " << __DJGPP__;
#ifdef __DJGPP_MINOR__
  oss << "." << __DJGPP_MINOR__;
#endif
  oss << ")";
#endif

#endif

// ------ Microsoft C++ ------
#ifdef _MSC_VER
  oss.str("");
  tss.str("");
  str.erase();

  oss << "Microsoft C++ ";
  tss << _MSC_VER;
  str = tss.str();
  assert (str.size() == 4);
  oss << str[0] << str[1] << "." << str[2] << str[3];

#ifdef _MANAGED

#if (_MANAGED)
  oss << " (Managed)";
#else
  assert (0);
  oss << " (Unmanaged)";
#endif
#else

  oss << " (Unmanaged)";
#endif

#endif

// ------ Intel C++ ------
#ifdef __INTEL_COMPILER
  oss.str("");
  tss.str("");
  str.erase();

  oss << "Intel C++ ";
  tss << __INTEL_COMPILER;
  str = tss.str();
  assert (str.size() == 3);
  oss << str[0] << "." << str[1];
#endif

// ------ Borland C++ ------
#ifdef __BCPLUSPLUS__
  oss.str("");
  tss.str("");
  str.erase();

  oss << "Borland C++ ";
  tss << hex << __BCPLUSPLUS__;
  str = tss.str();
  assert (str.size() == 3);
  oss << str[0] << "." << str[1] << "." << str[2];
#endif

// ------ Digital Mars C++ ------
#ifdef __DMC__
  oss.str("");
  tss.str("");
  str.erase();

#ifndef __DMC_VERSION_STRING__
#error __DMC_VERSION_STRING__ Not Defined
#endif
  oss << __DMC_VERSION_STRING__;
#endif

  return oss.str();

} // get_compiler_info

// --------------------------------------
void show_compiler_info()
{
const string str(get_compiler_info());

  if (str.empty()) return;

  cout << string (str.size(), '-') << endl;
  cout << str << endl;
  cout << string (str.size(), '-') << endl;
}

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com