读书人

#define后面的又是#号又是() _什么

发布时间: 2012-03-31 13:13:26 作者: rapoo

#define后面的又是#号,又是() __什么的,到哪里可以学到啊,什么书上有,我也想学学写那变态的玩意
RT

[解决办法]
http://www.cppreference.com/preprocessor/sharp.html
[解决办法]
#可以将后面的内容转换成字符串,如#*可以将* 转换成“*”
##是连接符如“Hello ”##“World”==“Hello World”
可以参看C/C++*精粹(人民邮电的一本书,名字记不太全)
还有《C语言参考大全》

[解决办法]
[推]《C语言的科学和艺术》,斯坦福的教授所著,公认的优秀教材。
书中教学用的库(http://download.csdn.net/user/RoderickA),
Dev C++(http://www.skycn.com/soft/4639.html).
[解决办法]
#if _MSC_VER > 1000
#pragma once // this file will be included (opened) only once by the compiler in a build
#endif
//_MSC_VER Defines the compiler version.
//Defined as 1200 for Microsoft Visual C++ 6.0. Always defined

#ifndef _INC_STRING
#define _INC_STRING
//in case of this file will be included repeated

#if !defined(_WIN32) && !defined(_MAC)
#error ERROR: Only Mac or Win32 targets supported!
#endif
//Say that only Mac or Win32 targets supported!

#ifdef __cplusplus
extern "C " {
#endif
//Defined for C++ programs only


/* Define _CRTIMP */

#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */
// Say that this file ' function will be import or export
//Defined when /MD or /MDd (Multithread DLL) is specified.

/* Define __cdecl for non-Microsoft compilers */

#if ( !defined(_MSC_VER) && !defined(__cdecl) )
#define __cdecl
#endif
//Say that only Mac or Win32 targets supported!
//Define C naming and calling conventions

/* Define _CRTAPI1 (for compatibility with the NT SDK) */

#ifndef _CRTAPI1
#if_MSC_VER > = 800 && _M_IX86 > = 300
#define _CRTAPI1 __cdecl
#else
#define _CRTAPI1
#endif
#endif
//For anther targets will be Supported


#ifndef _SIZE_T_DEFINED
typedef unsigned int size_t;
#define _SIZE_T_DEFINED
#endif
//define unsigned int as size_t


#ifndef _MAC
#ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED
#endif
#endif /* ndef _MAC */

#ifndef _NLSCMP_DEFINED
#define _NLSCMPERROR 2147483647 /* currently == INT_MAX */
#define _NLSCMP_DEFINED
#endif

/* Define NULL pointer value */

#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
//define NULL as 0

/* Function prototypes */

#ifdef _M_MRX000
_CRTIMP void * __cdecl memcpy(void *, const void *, size_t);
//_CRTIMP is defined :
//#ifndef _CRTIMP
//#ifdef _DLL
//#define _CRTIMP __declspec(dllimport)
//#else /* ndef _DLL */
//#define _CRTIMP
//#endif /* _DLL */
//#endif /* _CRTIMP */
...............................
......................
............
....
..
.
#endif
#endif
注:前面用英文注释的(用//的部分)。
总的来说,就是在预编译时该怎么处理。呵呵

读书人网 >C语言

热点推荐