想尝试下移植CUrl到WM下, 读源码先。
Curl为了跨平台, 提供了一个很好的config.h, 值得借鉴, Windows的适配代码如下:
curl\src\config-win32.h
1
#ifndef __SRC_CONFIG_WIN32_H
2 #define __SRC_CONFIG_WIN32_H
3
4 /* ================================================================ */
5 /* src/config-win32.h - Hand crafted config file for windows */
6 /* ================================================================ */
7
8 /* ---------------------------------------------------------------- */
9 /* HEADER FILES */
10 /* ---------------------------------------------------------------- */
11
12 /* Define if you have the <fcntl.h> header file. */
13 #define HAVE_FCNTL_H 1
14
15 /* Define if you have the <io.h> header file. */
16 #define HAVE_IO_H 1
17
18 /* Define if you have the <limits.h> header file. */
19 #define HAVE_LIMITS_H 1
20
21 /* Define if you have the <locale.h> header file. */
22 #define HAVE_LOCALE_H 1
23
24 /* Define if you need the malloc.h header file even with stdlib.h */
25 #if !defined(__SALFORDC__) && !defined(__POCC__)
26 #define NEED_MALLOC_H 1
27 #endif
28
29 /* Define if you have the <signal.h> header file. */
30 #define HAVE_SIGNAL_H 1
31
32 /* Define if you have the <stdlib.h> header file. */
33 #define HAVE_STDLIB_H 1
34
35 /* Define if you have the <sys/time.h> header file */
36 /* #define HAVE_SYS_TIME_H 1 */
37
38 /* Define if you have the <sys/types.h> header file. */
39 #define HAVE_SYS_TYPES_H 1
40
41 /* Define if you have the <sys/utime.h> header file. */
42 #ifndef __BORLANDC__
43 #define HAVE_SYS_UTIME_H 1
44 #endif
45
46 /* Define if you have the <time.h> header file. */
47 #define HAVE_TIME_H 1
48
49 /* Define if you have the <unistd.h> header file. */
50 #if defined(__MINGW32__) || defined(__WATCOMC__) || defined(__LCC__) || \
51 defined(__POCC__)
52 #define HAVE_UNISTD_H 1
53 #endif
54
55 /* Define if you have the <windows.h> header file. */
56 #define HAVE_WINDOWS_H 1
57
58 /* Define if you have the <winsock.h> header file. */
59 #define HAVE_WINSOCK_H 1
60
61 /* Define if you have the <winsock2.h> header file. */
62
2 #define __SRC_CONFIG_WIN32_H
3
4 /* ================================================================ */
5 /* src/config-win32.h - Hand crafted config file for windows */
6 /* ================================================================ */
7
8 /* ---------------------------------------------------------------- */
9 /* HEADER FILES */
10 /* ---------------------------------------------------------------- */
11
12 /* Define if you have the <fcntl.h> header file. */
13 #define HAVE_FCNTL_H 1
14
15 /* Define if you have the <io.h> header file. */
16 #define HAVE_IO_H 1
17
18 /* Define if you have the <limits.h> header file. */
19 #define HAVE_LIMITS_H 1
20
21 /* Define if you have the <locale.h> header file. */
22 #define HAVE_LOCALE_H 1
23
24 /* Define if you need the malloc.h header file even with stdlib.h */
25 #if !defined(__SALFORDC__) && !defined(__POCC__)
26 #define NEED_MALLOC_H 1
27 #endif
28
29 /* Define if you have the <signal.h> header file. */
30 #define HAVE_SIGNAL_H 1
31
32 /* Define if you have the <stdlib.h> header file. */
33 #define HAVE_STDLIB_H 1
34
35 /* Define if you have the <sys/time.h> header file */
36 /* #define HAVE_SYS_TIME_H 1 */
37
38 /* Define if you have the <sys/types.h> header file. */
39 #define HAVE_SYS_TYPES_H 1
40
41 /* Define if you have the <sys/utime.h> header file. */
42 #ifndef __BORLANDC__
43 #define HAVE_SYS_UTIME_H 1
44 #endif
45
46 /* Define if you have the <time.h> header file. */
47 #define HAVE_TIME_H 1
48
49 /* Define if you have the <unistd.h> header file. */
50 #if defined(__MINGW32__) || defined(__WATCOMC__) || defined(__LCC__) || \
51 defined(__POCC__)
52 #define HAVE_UNISTD_H 1
53 #endif
54
55 /* Define if you have the <windows.h> header file. */
56 #define HAVE_WINDOWS_H 1
57
58 /* Define if you have the <winsock.h> header file. */
59 #define HAVE_WINSOCK_H 1
60
61 /* Define if you have the <winsock2.h> header file. */
62
Curl还提供了config-max.h, 部分代码还有Symbian适配, 对于其他平台的移植是很方便的.
有些宏开关是为了支持较老的编译器, 自己用的话可以适当删去.