หน้าแรก > แท็> MinGW
MinGW
Directives
- 4 สิงหาคม 2010 12:00 น.
- วัสดุ
หมายเหตุ: เพื่อแยกส่วนของคำสั่ง preprocessor แพลตฟอร์มขึ้นอยู่กับเมื่อเขียนรหัสข้ามแพลตฟอร์ม
- คอมไพเลอร์
- GCC
- ifdef __ # GNUC__
- หรือมากกว่าถ้า __ # GNUC__> = 3 / / GCC3.0
- ifdef __ # GNUC__
- Borland C + +
- ifdef __ # BORLANDC__
- คอมไพเลอร์ของอินเทล
- # ifdef __ INTEL_COMPILER
- คอมไพเลอร์ของ Microsoft
- _MSC_VER # ifdef
- # VC ภายหลังหาก _MSC_VER> = 600 / / C Compiler 6.0 + ได้แก่
- # VC ภายหลังหาก _MSC_VER> = 700 / / C / C + + Compiler 7.0 + ได้แก่
- # ภายหลังหาก _MSC_VER> = 800 / / VC + 1.0
- # ภายหลังหาก _MSC_VER> = 900 / / VC + 2.0
- # ภายหลังหาก _MSC_VER> = 1000 / / VC + 4.0
- # ภายหลังหาก _MSC_VER> = 1010 / / VC + 4.1
- # ภายหลังหาก _MSC_VER> = 1020 / / VC + 4.2
- # ภายหลังหาก _MSC_VER> = 1100 / / VC + 5.0
- # ภายหลังหาก _MSC_VER> = 1200 / / VC + 6.0
- # ถ้า _MSC_VER> = 1300 / / VC2002 ภายหลัง (VC7.0)
- # ถ้า _MSC_VER> = 1310 / / VC2003 ภายหลัง (VC7.1)
- # ถ้า _MSC_VER> = 1400 / / VC2005 ภายหลัง (VC8.0)
- # ถ้า _MSC_VER> = 1500 / / VC2008 ภายหลัง (VC9.0)
- # ถ้า _MSC_VER> = 1600 / / VC2010 ภายหลัง (VC10.0)
- _MSC_VER # ifdef
- GCC
- ระบบ UNIX
- ยูนิกซ์
- # ifdef __ ยูนิกซ์
- ifdef __ # unix__
- ลินุกซ์
- # ifdef __ ลินุกซ์
- ifdef __ # linux__
- FreeBSD
- ifdef __ # FreeBSD__
- NetBSD
- ifdef __ # NetBSD__
- Cygwin
- ifdef __ # CYGWIN__
- # รุ่น Cygwin ifdef __ CYGWIN32__ / / 32bit
- MinGW (-mno-cygwin)
- ifdef __ # MINGW32__
- ยูนิกซ์
- ระบบ Windows
- CUI
- # ifdef _CONSOLE
- GUI
- _WINDOWS # ifdef
- ใช้ Windows 32bit
- WIN32 # ifdef
- # ifdef _WIN32
- ใช้ Windows 64bit
- # ifdef _WIN64
- รุ่น Windows
- WINVER # ifdef
- ตั้งแต่ # if (WINVER> = 0x030a) / / Windows 3.1
- ตั้งแต่ # 95 / NT4.0 (WINVER> = 0 × 0400) / Windows / ถ้า
- ตั้งแต่ # if (WINVER> = 0 × 0410) / / Windows 98
- ตั้งแต่ # if (WINVER> = 0 × 0500) / / Windows Me / 2000
- ตั้งแต่ # if (WINVER> = 0 × 0501) / / Windows XP / Server 2003
- # ตั้งแต่ปี 2003 SP1 (WINVER> = 0 × 0502) / / Windows XP SP2 / Server ถ้า
- ตั้งแต่ # if (WINVER> = 0 × 0600) / / Windows Vista / Server 2008
- ตั้งแต่ # if (WINVER> = 0 × 0601) / / Windows 7
- # ifdef _WIN32_WINDOWS / / Windows9x
- # หากภายหลัง (_WIN32_WINDOWS> = 0 × 0400) / / Windows 95
- # หากภายหลัง (_WIN32_WINDOWS> = 0 × 0410) / / Windows 98
- # หากภายหลัง (_WIN32_WINDOWS> = 0 × 0500) / / Windows Me
- # ifdef _WIN32_WINNT / / WindowsNTx
- / / ตั้งแต่ Windows 2000 (0 × 0500)
# ถ้า (_WIN32_WINNT> _WIN32_WINNT_WIN2K =) - / / ตั้งแต่ปี 2003 Windows XP / Server (0 × 0501)
# ถ้า (_WIN32_WINNT> = _WIN32_WINNT_WINXP) - / / พ. 2003 SP1 Windows XP SP2 / Server (0 × 0502)
# ถ้า (_WIN32_WINNT> = _WIN32_WINNT_WS03) - / / จาก Windows Vista (0 × 0600)
# ถ้า (_WIN32_WINNT> = _WIN32_WINNT_VISTA) - / / จาก Windows Server 2008 (0 × 0600)
# ถ้า (_WIN32_WINNT> = _WIN32_WINNT_WS08) - / / จาก Windows 7 (0 × 0601)
# ถ้า (_WIN32_WINNT> = _WIN32_WINNT_WIN7)
- / / ตั้งแต่ Windows 2000 (0 × 0500)
- # ifdef _WIN32_WCE / / WindowsCE
- # ถ้า (_WIN32_WCE> = 0 × 0420) / / Windows Mobile 2003 (PPC2003)
- # ถ้า (_WIN32_WCE> = 0 × 0421) / / Windows Mobile 2003 SE (PPC2003SE)
- # ถ้า (_WIN32_WCE> = 0 × 0501) / / Windows Mobile 5.0
- # ถ้า (_WIN32_WCE> = 0 × 0502) / / Windows Mobile 6 Professional / คลาสสิก
- # ถ้า (WINCEOSVER> = 0 × 0300) / / WindowsCE3.0 ภายหลัง (PPC2002)
- # ถ้า (WINCEOSVER> = 0 × 0420) / / WindowsCE4.2 ภายหลัง (PPC2003)
- # ถ้า (WINCEOSVER> = 0 × 0500) / / WindowsCE5.0 ภายหลัง (WM5.0)
- WINVER # ifdef
- รุ่น Internet Explorer
- _WIN32_IE # ifdef
- # ถ้า (_WIN32_IE> = 0 × 0200) / / Windows 95/NT 4.0 (Comctl32.dll 4.00, 4.00 Shell32.dll)
- # ถ้า (_WIN32_IE> = 0 × 0300) / / Internet Explorer 3.0, 3.01, 3.02
- # ถ้า (_WIN32_IE> = 0 × 0400) / / Internet Explorer 4.0
- # ถ้า (_WIN32_IE> = 0 × 0401) / / Internet Explorer 4.01
- # ถ้า (_WIN32_IE> = 0 × 0500) / / Internet Explorer 5.0, 5.0a, 5.0b
- # ถ้า (_WIN32_IE> = 0 × 0501) / / Internet Explorer 5.01
- # ถ้า (_WIN32_IE> = 0 × 0550) / / Internet Explorer 5.5
- # ถ้า (_WIN32_IE> = 0 × 0600) / / Internet Explorer 6.0
- # ถ้า (_WIN32_IE> = 0 × 0601) / Internet / Explorer 6.0 SP1
- # ถ้า (_WIN32_IE> = 0 × 0603) / Internet / Explorer 6.0 SP2
- # ถ้า (_WIN32_IE> = 0 × 0700) / / 7.0 Internet Explorer
- # ถ้า (_WIN32_IE> = 0 × 0800) / / Internet Explorer 8.0
- _WIN32_IE # ifdef
- CUI
หมายเหตุ preprocessor /> <br ในการรักษาเป็นตัวระบุที่ไม่ได้กำหนด 0, # ถ้า __ GNUC__> = 3 หรือมากขึ้น แต่สามารถใช้เป็น GCC3,
หากคุณพยายามที่จะกำหนด # ถ้า __ GNUC__ <3 ว่าระบบ GCC2, รวมถึงผู้ที่ไม่ได้เป็น GCC
การอ้างอิง
รับรุ่นของ Windows
- 29 กรกฎาคม 2010 12:00 น.
- วัสดุ
แต่ผมไม่คิดว่าฉันสามารถใช้คร่าวทราบ
ถ้าคอมไพเลอร์สามารถรวบรวมได้โดยไม่มีปัญหาและฉันคิดว่าระบบ Windows
แน่นอนรวบรวมและยืนยันการดำเนินการถูกหามออกใน MinGW
#include <windows.h> #include <stdio.h> int main(void) { unsigned int GV = GetVersion(); printf("GetVersion API(GV) = %08X\n\n", GV); printf("_winver = %08X\n", _winver); printf("_winmajor = %08X\n", _winmajor); printf("_winminor = %08X\n", _winminor); printf("_osver = %08X\n\n", _osver); printf("(( GV << 8 ) | (( GV >> 8 ) & 0XFF)) & 0XFFFF = %08X (= _winver)\n", (( GV << 8 ) | (( GV >> 8 ) & 0XFF)) & 0XFFFF ); printf("GV & 0XFF = %08X (= _winmajor)\n", GV & 0XFF ); printf("( GV >> 8 ) & 0XFF = %08X (= _winminor)\n", (( GV >> 8 ) & 0XFF)); printf("GV >> 16 = %08X (= _osver)\n\n\n", (GV >> 16) ); // Windows version(_winmajor, _winminor, _osver) printf("This system is ["); if ( _osver < 0X8000 ) { // NT Group (_osver LowWORD MSB = 0) switch (_winmajor) { case 3: case 4: printf ("Windows NT %u.%u Build %u", _winmajor, _winminor, _osver); break; case 5: switch (_winminor) { case 0: printf ("Windows 2000 Build %u", _osver); break; case 1: printf ("Windows XP Build %u", _osver); break; case 2: printf ("Windows Server 2003 family Build %u", _osver); break; default: printf ("NT Group Windows Build %u", _osver); } break; case 6: switch (_winminor) { case 0: printf ("Windows Vista or Windows Server 2008 Build %u", _osver); break; case 1: printf ("Windows 7 Build %u", _osver); break; default: printf ("NT Group Windows Build %u", _osver); } break; default: printf ("NTGroup Windows Build %u", _osver); } } else { switch (_winmajor ) { case 0: //Win32s Group case 1: case 2: case 3: printf ("Win32s Build %u", _osver & 0X7FFF); break; case 4: // 9X Group (_osver is invalid.) switch (_winminor) { case 0: printf ("Windows 95 Build ----"); break; case 10: printf ("Windows 98 Build ----"); break; case 90: printf ("Windows Me Build ----"); break; default: // To make sure printf ("Newer than Windows Me"); } break; default: // To make sure printf ("Newer than Windows Me"); } } printf("]"); return 0; } ส่วนที่ 2 รวบรวมกับ MinGW Jpegopitm
- 23 กรกฎาคม 2010 12:00 น.
- ซอฟต์แวร์
ฉันอาจจะมารวมกันในที่เดียวที่เป็นดังต่อไปนี้การแก้ไข changes'm เพิ่มเติมการเปลี่ยนแปลงของ Jpegoptim.c
@@ -53,6 +53,39 @@ #define ICC_IDENT_STRING "ICC_PROFILE\0" #define ICC_IDENT_STRING_SIZE 12 +#ifdef WIN32 +#define uid_t int +#define gid_t int +#define ROOT_UID 0 +#define ROOT_GID 0 +#define realpath(N,R) _fullpath((R),(N),_MAX_PATH) +uid_t getuid(void) +{ + return ROOT_UID; +} +uid_t geteuid(void) +{ + return ROOT_UID; +} +gid_t getgid(void) +{ + return ROOT_GID; +} +gid_t getegid(void) +{ + return ROOT_GID; +} +int setuid(uid_t uid) +{ + return (uid == ROOT_UID ? 0 : -1); +} +int setgid(gid_t gid) +{ + return (gid == ROOT_GID ? 0 : -1); +} + +#endif + void fatal(const char *msg); struct my_error_mgr { คอมไพล์ด้วย MinGW Jpegopitm
- 22 กรกฎาคม 2010 12:00 น.
- ซอฟต์แวร์
ฉัน stumbled ทราบเล็ก ๆ น้อย ๆ เพื่อรวบรวม Jpegoptim
- เปิดเครื่องรูดตำแหน่ง jpegoptim-1.2.3 ภายใต้ msys / src /
- เริ่ม msys ป้อนคำสั่งต่อไปนี้:
$ cd /src/jpegoptim-1.2.3/ $ autoconf $ configure - กำหนดค่าไม่ผ่านข้อผิดพลาดต่อไปนี้ออกมา
configure: error: cannot find install-sh, install.sh, or shtool in aux "."/aux - ที่จะแก้ไขดังนี้ configure.in
@@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(jpegoptim.c) AC_CONFIG_HEADER(config.h) -AC_CONFIG_AUX_DIR(aux) +AC_CONFIG_AUX_DIR(sub) AC_CANONICAL_HOST - สร้างโฟลเดอร์ย่อยนำมาจากสถานที่ที่เหมาะสมเช่นการติดตั้ง-SH (ในตัวอย่างจาก Jpeglib)
$ mkdir sub $ cp ../jpeg-6bx/install-sh ../jpeg-6bx/config.sub ../jpeg-6bx/config.guess ./sub - อีกครั้งเพื่อสร้างแฟ้มการกำหนดค่าให้เรียกใช้การกำหนดค่า
$ autoconf $ configure - หากคุณกำหนดค่าผ่านทางคุณทำงานให้ จากนั้นได้รับข้อผิดพลาดต่อไปนี้:
jpegoptim.c:354: undefined reference to 'realpath' jpegoptim.c:354: undefined reference to 'realpath' - ที่จะแก้ไขดังต่อไปนี้ jpegoptim.c
@@ -351,7 +351,11 @@ } break; case 'd': - if (realpath(optarg,dest_path)==NULL || !is_directory(dest_path)) { +#ifdef WIN32 + if (_fullpath(dest_path,optarg,MAXPATHLEN)==NULL || !is_directory(dest_path)) { +#else + if (realpath(optarg,dest_path)==NULL || !is_directory(dest_path)) { +#endif fatal("invalid argument for option -d, --dest"); } if (verbose_mode) @@ -441,8 +445,13 @@ fatal("splitdir() failed!"); strncpy(newname,argv[i],sizeof(newname)); } - snprintf(tmpfilename,sizeof(tmpfilename), +#ifdef WIN32 + snprintf(tmpfilename,sizeof(tmpfilename), + "%sjpegoptim-%d.tmp", tmpdir, (int)getpid()); +#else + snprintf(tmpfilename,sizeof(tmpfilename), "%sjpegoptim-%d-%d.tmp", tmpdir, (int)getuid(), (int)getpid()); +#endif } retry_point: - อีกครั้งการรวบรวมจะถูกส่งในให้
มันแม้ว่ามันจะเป็นชื่อโฟลเดอร์สคริปต์ aux เสริมเช่นการติดตั้ง-SH เป็นที่ระลึกของแต่ละระบบ BSD,
คุณไม่สามารถสร้างโฟลเดอร์ที่ชื่อว่า aux โฟลเดอร์พิเศษในเศษของ DOS ใน Windows
ดังนั้นเราจึงเก็บบางชนิดสคริปต์ที่ช่วยเสริมการเปลี่ยนลำดับที่ "ย่อย" คุณสามารถสร้าง "ย่อย" โฟลเดอร์ใหม่ซึ่งรวมอยู่ในซอฟต์แวร์ระบบ GNU
นอกจากนี้ getuid realpath และที่อยู่ในข้อผิดพลาดที่รวบรวมเวลาเป็นหน้าที่ของระบบ POSIX
ได้ถูกลบหรือถูกแทนที่ด้วยคนที่ทำงานเดียวกันหรือเพราะ Windows ไม่มีอยู่
ผมมีดีกว่าที่เขียนมันสวยงามมากขึ้นในตัวอย่างของเรา แต่แทนที่ realpath เพื่อที่จะผ่านการคอมไพล์ _fullpath
หน้าแรก > แท็> MinGW
- ค้นหา
- อาหาร
- การแปล










