Inizio > tag> MinGW

MinGW

Direttive

Nota per isolare la parte delle direttive del preprocessore dipendenti dalla piattaforma durante la scrittura di codice cross-platform.

  • Compiler
    • GCC
      • # Ifdef __ GNUC__
        • O più # if __ GNUC__> = 3 / / GCC3.0
    • Borland C + +
      • # Ifdef __ BORLANDC__
    • Intel Compiler
      • # Ifdef __ INTEL_COMPILER
    • Microsoft Compiler
      • # Ifdef _MSC_VER
        • # VC in seguito, se _MSC_VER> = 600 / / C Compiler 6.0 + + compreso
        • # VC in seguito, se _MSC_VER> = 700 / / C / C + + Compiler 7.0 + + compreso
        • # Se poi _MSC_VER> = 800 / / VC + 1,0
        • # Se poi _MSC_VER> = 900 / / VC + 2,0
        • # Se poi _MSC_VER> = 1000 / / VC + 4,0
        • # Se poi _MSC_VER> = 1010 / / VC + 4,1
        • # Se poi _MSC_VER> = 1020 / / VC + 4,2
        • # Se poi _MSC_VER> = 1100 / / VC + 5,0
        • # Se poi _MSC_VER> = 1200 / / VC + 6,0
        • # Se _MSC_VER> = 1300 / / VC2002 più tardi (VC7.0)
        • # Se _MSC_VER> = 1310 / / VC2003 più tardi (VC7.1)
        • # Se _MSC_VER> = 1400 / / VC2005 più tardi (VC8.0)
        • # Se _MSC_VER> = 1500 / / VC2008 più tardi (VC9.0)
        • # Se _MSC_VER> = 1600 / / VC2010 più tardi (VC10.0)
  • Sistema UNIX
    • UNIX
      • # Ifdef __ unix
      • # Ifdef __ unix__
    • Linux
      • # Ifdef __ linux
      • # Ifdef __ linux__
    • FreeBSD
      • # Ifdef __ FreeBSD__
    • NetBSD
      • # Ifdef __ NetBSD__
    • Cygwin
      • # Ifdef __ CYGWIN__
      • # Ifdef __ versione Cygwin CYGWIN32__ / / 32bit
    • MinGW (-mno-cygwin)
      • # Ifdef __ MINGW32__
  • Di sistema di Windows
    • CUI
      • # Ifdef _CONSOLE
    • GUI
      • # Ifdef _WINDOWS
    • Windows a 32 bit
      • # Ifdef WIN32
      • # Ifdef _WIN32
    • Windows a 64 bit
      • # Ifdef _WIN64
    • Versione di Windows
      • # Ifdef WINVER
        • Dal # if (WINVER> = 0x030a) / / Windows 3.1
        • # Dal 95 / NT4.0 (WINVER> = 0 × 0400) / / Windows se
        • Dal # if (WINVER> = 0 × 0410) / / Windows 98
        • Dal # if (WINVER> = 0 × 0500) / / Windows Me / 2000
        • Dal # if (WINVER> = 0 × 0501) / / Windows XP / Server 2003
        • # Dal 2003 SP1 (WINVER> = 0 × 0502) / / Windows XP SP2 / Server, se
        • Dal # if (WINVER> = 0 × 0600) / / Windows Vista / Server 2008
        • Dal # if (WINVER> = 0 × 0601) / / Windows 7
      • # Ifdef _WIN32_WINDOWS / / Windows9x
        • # Se più tardi (_WIN32_WINDOWS> = 0 × 0400) / / Windows 95
        • # Se più tardi (_WIN32_WINDOWS> = 0 × 0410) / / Windows 98
        • # Se più tardi (_WIN32_WINDOWS> = 0 × 0500) / / Windows Me
      • # Ifdef _WIN32_WINNT / / WindowsNTx
        • / / Dal momento che Windows 2000 (0 × 0500)
          # Se (_WIN32_WINNT> _WIN32_WINNT_WIN2K =)
        • / / Dal 2003 Windows XP / Server (0 × 0501)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_WINXP)
        • / / Dal 2003 SP1 di Windows XP SP2 / Server (0 × 0502)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_WS03)
        • / / Da Windows Vista (0 × 0600)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_VISTA)
        • / / Da Windows Server 2008 (0 × 0600)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_WS08)
        • / / Da Windows 7 (0 × 0601)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_WIN7)
      • # Ifdef _WIN32_WCE / / WindowsCE
        • # Se (_WIN32_WCE> = 0 × 0420) / / Windows Mobile 2003 (PPC2003)
        • # Se (_WIN32_WCE> = 0 × 0421) / / Windows Mobile 2003 SE (PPC2003SE)
        • # Se (_WIN32_WCE> = 0 × 0501) / / Windows Mobile 5.0
        • # Se (_WIN32_WCE> = 0 × 0502) / / Windows Mobile 6 Professional / Classic
        • # Se (WINCEOSVER> = 0 × 0300) / / WindowsCE3.0 più tardi (PPC2002)
        • # Se (WINCEOSVER> = 0 × 0420) / / WindowsCE4.2 più tardi (PPC2003)
        • # Se (WINCEOSVER> = 0 × 0500) / / WindowsCE5.0 più tardi (WM5.0)
    • Internet Explorer versione
      • # Ifdef _WIN32_IE
        • # Se (_WIN32_IE> = 0 × 0200) / / Windows 95/NT 4.0 (Comctl32.dll 4,00, Shell32.dll 4.00)
        • # Se (_WIN32_IE> = 0 × 0300) / / Internet Explorer 3.0, 3.01, 3.02
        • # Se (_WIN32_IE> = 0 × 0400) / / Internet Explorer 4.0
        • # Se (_WIN32_IE> = 0 × 0401) / / Internet Explorer 4.01
        • # Se (_WIN32_IE> = 0 × 0500) / / Internet Explorer 5.0, 5.0a, 5.0b
        • # Se (_WIN32_IE> = 0 × 0501) / / Internet Explorer 5.01
        • # Se (_WIN32_IE> = 0 × 0550) / / Internet Explorer 5.5
        • # Se (_WIN32_IE> = 0 × 0600) / / Internet Explorer 6.0
        • # If (_WIN32_IE> = 0 × 0601) / / Internet Explorer 6.0 SP1
        • # Se (_WIN32_IE> = 0 × 0603) / / Internet Explorer 6.0 SP2
        • # Se (_WIN32_IE> = 0 × 0700) / / Internet Explorer 7.0
        • # Se (_WIN32_IE> = 0 × 0800) / / Internet Explorer 8.0

Nota <br /> preprocessore, a considerare come identificatore undefined 0, # if __ GNUC__> = 3 o più, ma può essere utilizzato come gcc3,
Se si tenta di stabilire # if __ GNUC__ <3 se il sistema GCC2, comprendono quelli che non sono GCC.
Riferimento

Ottiene la versione di Windows

Ma io non credo di poter utilizzare, provvisoriamente nota.
Se il compilatore può essere compilato senza problemi e penso di sistema di Windows.
Timidamente, compilare e confermare l'operazione è stata effettuata in 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; } 

Parte 2 compilato con MinGW la Jpegopitm

Potrei si fondono in un unico luogo dove è più fix a seguito di un cambiamento di 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 { 

Compilato con MinGW la Jpegopitm

Mi sono imbattuto una piccola nota per compilare il jpegoptim.

  1. Decomprimere il posizionamento jpegoptim-1.2.3 in msys / src /
  2. Avviare MSYS, immettere i seguenti comandi:
     $ cd /src/jpegoptim-1.2.3/ $ autoconf $ configure 
  3. configurare non passa, il seguente errore uscire
     configure: error: cannot find install-sh, install.sh, or shtool in aux "."/aux 
  4. essere modificato come segue 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 
  5. Creare una cartella secondaria, portare dal luogo appropriato, ad esempio install-sh (nell'esempio da Jpeglib)
     $ mkdir sub $ cp ../jpeg-6bx/install-sh ../jpeg-6bx/config.sub ../jpeg-6bx/config.guess ./sub 
  6. Ancora una volta, di generare un file configure, eseguire il configure
     $ autoconf $ configure 
  7. Se si configura attraverso, si esegue il make. Poi ottenere i seguenti errori:
     jpegoptim.c:354: undefined reference to 'realpath' jpegoptim.c:354: undefined reference to 'realpath' 
  8. essere modificato come segue 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: 
  9. Ancora una volta, la compilazione viene passato nel fare.

esso, anche se è cartella denominata aux scripts ausiliari come install-sh è una reliquia del sistema ogni BSD,
Non è possibile creare una cartella denominata cartella aux speciale i resti di DOS in Windows.
Pertanto, memorizzare alcuni tipi di script ausiliari per cambiare le "Sub" riferimenti, è possibile creare una cartella "sub" nuova, che è incluso nel software di sistema GNU.
Inoltre, getuid realpath e che era in errore in fase di compilazione è una funzione del sistema POSIX
È stato eliminato o sostituito con uno che funziona lo stesso o perché Windows non esiste.
Ho avuto meglio riscriverlo più bello nel nostro esempio, ma ha sostituito il realpath per passare il _fullpath compilation

Inizio > tag> MinGW

Cerca
Alimentare
Traduzione
Japanese flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagEnglish flagGerman flagFrench flagRussian flagVietnamese flagThai flag

Torna all'inizio della pagina