Questions tagged «redefinition»

16
C ++重新定义头文件(winsock2.h)
如何防止两次包含头文件?问题是我包括在MyClass.h中,然后在许多文件中包含MyClass.h,因此它包含多次,并且发生重定义错误。怎么预防? 我使用#pragma一次而不是使用包括卫兵,我想那很好。 MyClass.h: // MyClass.h #pragma once #include <winsock2.h> class MyClass { // methods public: MyClass(unsigned short port); virtual ~MyClass(void); }; 编辑:我得到的错误很少 c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(460) : see previous definition of 'AF_IPX' c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(124) : warning C4005: 'AF_MAX' : macro …
143 c++  header  redefinition 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.