원문 출처 : http://msdn.microsoft.com/en-us/library/b0084kay.aspx

Predefined Macro 가 참 많은데, 몇가지 자주 쓰는 것만 정리해봅니다.



_MSC_VER

Evaluates to the major and minor number components of the compiler's version number. The major number is the first component of the period-delimited version number and the minor number is the second component.

For example, if the version number of the Visual C++ compiler is 15.00.20706.01, the _MSC_VER macro evaluates to 1500.

In Visual Studio 2010, _MSC_VER is defined as 1600.



_DEBUG

Defined when you compile with /LDd, /MDd, and /MTd. 



__FUNCTION__ / __FUNCTIONW__

Valid only in a function. Defines the undecorated name of the enclosing function as a string.

__FUNCTION__ is not expanded if you use the /EP or /P compiler option.

See __FUNCDNAME__ for an example. 
원문 출처 : http://www.openoffice.org/servlets/ReadMsg?msgId=930121&listName=dev


제목 [dev] A Static Assert implementation
표준 보기 메시지 원본 데이터 출력
Date: Tue, 11 Nov 2003 12:10:11 +0000
From: Caolan McNamara <Caolan.McNamara@Sun.COM>
Content-type: text/plain
Subject: [dev] A Static Assert implementation

We've a number of assert macros which could more profitably be picked up during compile time rather than at run time. Here's an implementation of a staticassert that I've been using successfully in the ww8 filter implemented as sw/source/filter/ww8/inc/staticassert.hxx for some time. An example usage is

StaticAssert((sizeof(stiName) / sizeof(stiName[0])) == 77,
    WrongSizeOfArray);
The constraints are that the error message is a plausible class name, i.e. no spaces and that the test can be done at compile time, e.g. array size checking etc. Perhaps this would be useful moved elsewhere as an office wide construct, instead of just for the ww8 filter.

/*
 Lifted direct from:
 Modern C++ Design: Generic Programming and Design Patterns Applied
 Section 2.1
 by Andrei Alexandrescu
*/
namespace ww
{
    template<bool> class compile_time_check
    {
    public:
        compile_time_check(...) {}
    };

    template<> class compile_time_check<false>
    {
    };
}

    /*
    Similiar to assert, StaticAssert is only in operation when NDEBUG
    is not defined. It will test its first argument at compile time 
    and on failure report the error message of the second argument,
    which must be a valid c++ classname. i.e. no spaces, punctuation 
    or reserved keywords.
    */
#ifndef NDEBUG
#   define StaticAssert(test, errormsg)                         \
    do {                                                        \
        struct ERROR_##errormsg {};                             \
        typedef ww::compile_time_check< (test) != 0 > tmplimpl; \
        tmplimpl aTemp = tmplimpl(ERROR_##errormsg());          \
        sizeof(aTemp);                                          \
    } while (0)
#else
#   define StaticAssert(test, errormsg)                         \
    do {} while (0)
#endif

C.
-- 
Caolan McNamara <Caolan.McNamara@Sun.COM>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@openoffice.org
For additional commands, e-mail: dev-help@openoffice.org

+ Recent posts