A couple updates to this thread:
1) We don't need to define MSVC to detect MSVC. MSVC already defines _MSC_VER as the current major and minor version of the (MSVC) compiler. It is not defined in MinGW or Cygwin. As a side note, it looks like the Intel compiler defines it, but lets not go there. 3 Windows platforms are enough. :)
2) hr_swrun.c does not compile under Cygwin because it includes winsock.h for Cygwin because WIN32 is defined. We need to either always define WIN32 for Cygwin, or never. It appears to only be defined when compiling the mibs which doesn't make sense. See http://sourceforge.net/mailarchive/message.php?msg_id=11531832 and my previous comments at the bottom of this message.
Thinking more about Andy's statement "Keeping Cygwin separate in most cases still makes sense because a lot of POSIX code will compile out of the box with Cygwin" makes me think that it's probably a good idea for WIN32 to be defined for MinGW and MSVC, but not Cygwin. Cygwin can be treated as it's own complete system, like 'Linux'. Some searching on Google makes me think this is what most people prefer.
If there are no objections, I would like to clean up the ifdefs for WIN32, mingw and cygwin and document it as:
Define: Description: ------- ------------ WIN32 Defined by MSVC & MinGW
_MSC_VER Defined by MSVC only (standard MSVC macro)
mingw32 Defined by MinGW only
cygwin Defined by Cygwin only
HAVE_WIN32_PLATFORM_SDK Should be defined if the Microsoft Platform SDK
is installed and registered with MSVC or
enabled for MinGW or CygwinNote: MinGW and Cygwin do not require the Platform SDK as they both
contain most if not all of the functionality provided by the SDK.
When adding code that requires the PSDK under MSVC, the following
can usually be used: #if defined (HAVE_WIN32_PLATFORM_SDK) || defined (mingw32) ||
defined (cygwin)Alex
Alex Burger wrote:
Hi Andy.
I was under the impression that MinGW and Cygwin both natively defined WIN32 like MSVC. I just did a quick check, and only MinGW defines it. I tried modifying configure.in so -DWIN32 is added to the CFLAGS when Cygwin is detected, but then the compile stops with:
../include/net-snmp/library/snmp_alarm.h:17: error: field `t' has incomplete type
Also, while modifying system_mib.c so that the windowsOSVersionString function would be compiled under all three Win32 platforms, I found that it would not compile under Cygwin. After adding the following to system_mib.c, it compiled fine:
#ifdef cygwin #include <windows.h> #endif
I noticed that the mibII_common.h file defines WIN32 at the bottom if cygwin is detected, but this file was not included in system_mib.c. Including it didn't even seem to help. I can add the above in as a quick fix, but I wonder if it should really be #ifdef WIN32..
I was going to add a section to README.WIN32 that lists the defines that are used with the three supported Windows build systems. Here is what I was planning on adding:
*** Define: Description: ------- ------------
WIN32 Defined by MSVC, MinGW and Cygwin
MSVC Defined by MSVC only
mingw32 Defined by MinGW only
cygwin Defined by Cygwin only
HAVE_WIN32_PLATFORM_SDK Should be defined if the Microsoft Platform SDK is installed and registered with MSVC or enabled for MinGW or Cygwin
Note: MinGW and Cygwin do not require the Platform SDK as they both contain most if not all of the functionality provided by the PSDK. When adding code that requires the PSDK under MSVC, the following can usually be used:
#if defined (HAVE_WIN32_PLATFORM_SDK) || defined (mingw32) || defined (cygwin)
***
Based on my findings above, the notes about Cygwin defining WIN32 are incorrect. I think it makes sense that WIN32 would cover ALL Windows platforms, while MSVC, mingw32 and cygwin could be specific to each build system. You mentioned before: "Keeping Cygwin separate in most cases still makes sense because a lot of POSIX code will compile out of the box with Cygwin". I agree with this, but having WIN32 only defined for MSVC and MinGW but not Cygwin is kind of strange.
What do you think?
Alex
------------------------------------------------------- SF.Net email is sponsored by: Tell us your software development plans! Take this survey and enter to win a one-year sub to SourceForge.net Plus IDC's 2005 look-ahead and a copy of this survey Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
