subject_19259.htm
来自「一些关于vc的问答」· HTM 代码 · 共 36 行
HTM
36 行
<p>
序号:19259 发表者:小小申 发表日期:2002-10-27 11:45:19
<br>主题:请问#ifndef#define#endif怎么用啊?
<br>内容:看MSDN都看不懂,请问#ifndef#define#endif怎么用啊?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:木子 回复日期:2002-10-27 13:27:49
<br>内容:这些是编译命令,决定程序执不执行其中包含的命令<BR>#ifdef STDENT<BR>...<BR>#endif<BR>如果在#ifdef之前声明过STUDENT,则执行其中的命令,否则,不执行<BR>#ifndef STUDENT<BR>...<BR>#endif<BR>如果在#ifndef之前没有声明过STUDENT,则执行其中的命令,否则,不执行
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小小申 回复日期:2002-10-27 13:57:06
<br>内容:#ifndef STDINC_H//STDINC_H这代表当前文件,你的意思是为减少重复include此头文件<BR>#define STDINC_H//其实我也有此理解、再看看后面的<BR><BR><BR>//<BR>// Visual C++ has cannot manage debug infor for symbols greater than 255<BR>// characters. However, it is easy to have symbol lengths greater than 255 <BR>// when using the STL. Therefore, I'm disabling this warning here.<BR>//<BR>#pragma warning(disable: 4786)<BR><BR><BR>//<BR>// This is, after all, a book about DCOM...<BR>//<BR>#define _WIN32_DCOM<BR><BR><BR>//<BR>// If either of the ATL flags are set, then we're using ATL (duh!)<BR>//<BR>#ifdef USE_ATL<BR> #error Please specify USE_ATL_INPROC or USE_ATL_LOCAL to indicate your project uses ATL<BR>#endif<BR>#ifdef USE_ATL_INPROC<BR> #define USE_ATL<BR>#endif<BR>#ifdef USE_ATL_LOCAL<BR> #define USE_ATL<BR>#endif<BR><BR><BR>//<BR>// Are console operations available?<BR>//下面这段怎么理解、这里跟include没关了吧<BR>//USE_MFC代表什么啊、<BR>//也没看到以后的文件使用此家伙啊<BR>//他的意思使用MFC就象输出DOS命令行的,<BR>//使用ATL也一样的<BR>#ifdef USE_MFC<BR> #define NO_CONSOLE<BR>#endif<BR>#ifdef USE_ATL<BR> // Not strictly true, of course<BR> #define NO_CONSOLE<BR>#endif<BR><BR><BR>//<BR>// We ARE using MFC<BR>//<BR>#ifdef USE_MFC<BR> #include <afxwin.h><BR> #include <afxcmn.h><BR> #include <afxext.h><BR> #include <afxdisp.h><BR> #include <cguid.h><BR> #include <afxctl.h><BR> #include <afxtempl.h><BR> #include <afxdlgs.h><BR><BR><BR>//<BR>// We are not using MFC<BR>//<BR>#else USE_MFC<BR><BR> //<BR> // Get basic Windows stuff<BR> //<BR> #define STRICT<BR> #ifndef NO_INC_OLE2<BR> #define INC_OLE2<BR> #include <windows.h><BR> #include <ole2.h><BR> #else<BR> #include <windows.h><BR> #endif<BR> #include <cguid.h><BR><BR>#endif<BR><BR><BR>//<BR>// We ARE using ATL<BR>//<BR>#ifdef USE_ATL<BR> // #define _WIN32_WINNT 0x0400<BR> #define _ATL_APARTMENT_THREADED<BR> #include <atlbase.h><BR><BR> // What is our module class? This is a utility header, it should<BR> // be found in the same diredctory as this file<BR> #include "atlmod.h"<BR><BR> #include <atlcom.h><BR>#endif<BR><BR><BR>// Some helpful type aliases<BR>typedef PVOID* PPVOID;<BR>typedef unsigned char UCHAR;<BR>typedef unsigned char* PUCHAR;<BR>typedef unsigned short USHORT;<BR>typedef unsigned short* PUSHORT;<BR>typedef unsigned long ULONG;<BR>typedef unsigned long* PULONG;<BR>typedef BSTR* PBSTR;<BR><BR>#endif
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小小申 回复日期:2002-10-27 13:58:46
<br>内容:讲得还是不是很清楚啊
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小小申 回复日期:2002-10-27 17:47:09
<br>内容:<BR>#ifdef STDENT<BR>...<BR>#endif<BR>如果在#ifdef之前声明过STUDENT,则执行其中的命令,否则,不执行<BR><BR>在我贴的头文件中,以后的其他文件都没用到USE_MFC和USE_ATL<BR>我怎么知道是USE_MFC还是USE_ATL
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小小申 回复日期:2002-10-27 23:24:22
<br>内容:对了,那个头文件是一个DCOM的例子里的<BR>#ifndef STDINC_H//<BR>#define STDINC_H//<BR><BR>//<BR>// Visual C++ has cannot manage debug infor for symbols greater than 255<BR>// characters. However, it is easy to have symbol lengths greater than 255 <BR>// when using the STL. Therefore, I'm disabling this warning here.<BR>//<BR>#pragma warning(disable: 4786)<BR><BR><BR>//<BR>// This is, after all, a book about DCOM...<BR>//<BR>#define _WIN32_DCOM<BR><BR><BR>//<BR>// If either of the ATL flags are set, then we're using ATL (duh!)<BR>//<BR>#ifdef USE_ATL<BR> #error Please specify USE_ATL_INPROC or USE_ATL_LOCAL to indicate your project uses ATL<BR>#endif<BR>#ifdef USE_ATL_INPROC<BR> #define USE_ATL<BR>#endif<BR>#ifdef USE_ATL_LOCAL<BR> #define USE_ATL<BR>#endif<BR><BR><BR>//<BR>// Are console operations available?<BR>//#ifdef USE_MFC<BR> #define NO_CONSOLE<BR>#endif<BR>#ifdef USE_ATL<BR> // Not strictly true, of course<BR> #define NO_CONSOLE<BR>#endif<BR><BR><BR>//<BR>// We ARE using MFC<BR>//<BR>#ifdef USE_MFC<BR> #include <afxwin.h><BR> #include <afxcmn.h><BR> #include <afxext.h><BR> #include <afxdisp.h><BR> #include <cguid.h><BR> #include <afxctl.h><BR> #include <afxtempl.h><BR> #include <afxdlgs.h><BR><BR><BR>//<BR>// We are not using MFC<BR>//<BR>#else USE_MFC<BR><BR> //<BR> // Get basic Windows stuff<BR> //<BR> #define STRICT<BR> #ifndef NO_INC_OLE2<BR> #define INC_OLE2<BR> #include <windows.h><BR> #include <ole2.h><BR> #else<BR> #include <windows.h><BR> #endif<BR> #include <cguid.h><BR><BR>#endif<BR><BR><BR>//<BR>// We ARE using ATL<BR>//<BR>#ifdef USE_ATL<BR> // #define _WIN32_WINNT 0x0400<BR> #define _ATL_APARTMENT_THREADED<BR> #include <atlbase.h><BR><BR> // What is our module class? This is a utility header, it should<BR> // be found in the same diredctory as this file<BR> #include "atlmod.h"<BR><BR> #include <atlcom.h><BR>#endif<BR><BR><BR>// Some helpful type aliases<BR>typedef PVOID* PPVOID;<BR>typedef unsigned char UCHAR;<BR>typedef unsigned char* PUCHAR;<BR>typedef unsigned short USHORT;<BR>typedef unsigned short* PUSHORT;<BR>typedef unsigned long ULONG;<BR>typedef unsigned long* PULONG;<BR>typedef BSTR* PBSTR;<BR><BR>#endif <BR><BR>我的意思<BR>我再问中间那段<BR>以后的其他文件都没出现USE_MFC和USE_ATL<BR>都没用到USE_MFC和USE_ATL<BR>我怎么知道是USE_MFC还是USE_ATL <BR><BR>还有<BR>#ifndef<BR>#define STUDENT<BR>#endif<BR><BR>STUDENT有没有值的?如果有,是不是随机值?<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?