Files
boost_predef/libs/predef/test/info_as_cpp.cpp
T
Rene Rivera 7f08aede99 Partial work on changes post-review of Predef library:
* shorter category names
* CXX => COMP to be generic compiler category
* add predef for string name of item
* renamed all version make/extraction macros for clarity
* C++ standard predef to use 1970.0.0 epoc date offset
* subcategories for OS_BSD
* start rewrite to support older preprocessors

git-svn-id: http://svn.boost.org/svn/boost/sandbox/predef@79517 b8fc166d-592f-0410-95f2-cb63ce0dd405
2012-07-15 03:37:23 +00:00

91 lines
1.7 KiB
C++

/*
Copyright Redshift Software Inc. 2011-2012
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
#include <string>
#include <iostream>
#include <set>
#define BOOST_PREDEF_INTERNAL_GENERATE_TESTS
namespace
{
struct predef_info
{
std::string name;
std::string description;
unsigned value;
predef_info(
std::string const & n,
std::string const & d,
unsigned v);
predef_info(
predef_info const & other)
: name(other.name)
, description(other.description)
, value(other.value)
{
}
bool operator < (predef_info const & other) const
{
return name < other.name;
}
};
std::set<predef_info> * predefs = 0;
predef_info::predef_info(
std::string const & n,
std::string const & d,
unsigned v)
: name(n)
, description(d)
, value(v)
{
if (!predefs)
{
predefs = new std::set<predef_info>();
}
predefs->insert(*this);
}
}
#define BOOST_PREDEF_DECLARE_TEST(x,s) \
namespace { \
predef_info x##_predef_init(#x,s,x); \
}
#include <boost/predef.h>
int main()
{
std::set<predef_info>::iterator i;
std::set<predef_info>::iterator e = predefs->end();
std::cout << "** Detected **" << std::endl;
for (i = predefs->begin(); i != e; ++i)
{
if (i->value > 0)
std::cout
<< i->name << " = "
<< i->value
<< " (" << (i->value/10000000)%100 << "," << (i->value/100000)%100 << "," << (i->value)%100000 << ") | "
<< i->description
<< std::endl;
}
std::cout << "** Not Detected **" << std::endl;
for (i = predefs->begin(); i != e; ++i)
{
if (i->value == 0)
std::cout
<< i->name << " = "
<< i->value << " | "
<< i->description
<< std::endl;
}
return 0;
}