Presentation is loading. Please wait.

Presentation is loading. Please wait.

Predefined Macros (examples)

Similar presentations


Presentation on theme: "Predefined Macros (examples)"— Presentation transcript:

1 Predefined Macros (examples)
GCC: __GNUC__ __STRICT_ANSI__ (When strict ANSI applied) __linux__ (On linux systems) __FreeBSD__ (Another variant of unix) __hp9000s700__ (HP workstations) CL (VC++): WIN32, _WINDOWS, _MSC_VER (Version number) NDEBUG (Release version) DEBUG, _DEBUG (Debug version)

2 Malloc / Free Macros #ifdef _DEBUG
VoidPtr XXXXMalloc(unsigned Size, char *ObjType, char *FileName, int LineNum); #define XXXXMalloc(x) XXXXMalloc((x), #x, \ __FILE__, __LINE__) void XXXXFree(VoidPtr p); #define XXXXFree(x) { XXXXFree(x); x = NULL; } #else #define XXXXMalloc(Size) malloc(Size) #define XXXXFree(Ptr) free(Ptr) #endif /* _DEBUG */

3 MACRO examples # if defined(OSF1DEC) || defined(sgi) || defined(SUN4) || \ defined(OS2GCC) || defined(__FreeBSD__) # ifdef OSF1DEC # ifdef _XOPEN_SOURCE # undef _XOPEN_SOURCE /* For usleep */ # endif /* _XOPEN_SOURCE */ # endif /* OSF1DEC */ # include <unistd.h> # endif /* OSF1DEC || sgi || SUN4 || OS2GCC || FreeBSD */ # ifdef __WINNT__ # include <direct.h> # if _MSC_VER >= /* Visual 8, 2005 */ # define mkdir(Dir, Permit) _mkdir(Dir) # else # define mkdir(Dir, Permit) mkdir(Dir) # endif /* _MSC_VER >= 1400 */ # endif /* __WINNT__ */

4 memcpy C function void *memcpy(void *dest, const void *src, int count);

5 qsort C function void qsort(void *base_array, int num_elem, size_elem,
int (*compare )(const void *, const void *));


Download ppt "Predefined Macros (examples)"

Similar presentations


Ads by Google