[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppMacro
Avoid macro's [1,2].
One of the few exceptions is the assert statement, which can be used for debugging.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppMacro
(C++) Macro
A preprocessor function.Avoid macro's [1,2].
//Macro function//Correct C++ alternative template <typename T> inline T max(const T& a, const T& b) return ( a > b ? a : b);
- define MAX(A,B) ( A > B ? A : B )
One of the few exceptions is the assert statement, which can be used for debugging.
C++ Standard macro’s [3]
_IOFBF _IOLBF _IONBF assert BUFSIZ CLOCKS_PER_SEC EDOM EOF ERANGE errno EXIT_FAILURE EXIT_SUCCESS FILENAME_MAX FOPEN_MAX HUGE_VAL L_tmpnam LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME MB_CUR_MAX NULL (in cstddef) NULL (in cstdio) NULL (in cstring) NULL (in ctime) NULL (in cwchar) offsetof RAND_MAX SEEK_CUR SEEK_END SEEK_SET setjmp SIG_DFL SIG_ERR SIG_IGN SIGABRT SIGFPE SIGILL SIGINT SIGSEGV SIGTERM stderr stdin stdout TMP_MAX va_arg va_end va_start WCHAR_MAX WCHAR_MIN WEOF (in cwchar) WEOF (in cwctype)
'Macro' links
References
- 1) Bjarne Stroustrup. The C++ Programming Language (3rd edition).ISBN: 0-201-88954-4, chapter 7.9.4: 'Avoid macros'
- 2) Herb Sutter and Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Chapter 16: 'Avoid macros'.
- 3) The C++ International Standard. 2003 (2nd edition). ISO/IEC 14882. Table 95.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
