Changeset 123


Ignore:
Timestamp:
02/10/14 17:08:23 (11 years ago)
Author:
sz
Message:

Cygwin compatibility

Location:
cpp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/nonstd.h

    r109 r123  
     1// This file is a part of the Framsticks GDK.
     2// Copyright (C) 2002-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
     3// Refer to http://www.framsticks.com/ for further information.
     4
    15#ifndef _NONSTD_H_
    26#define _NONSTD_H_
     
    1822// ms visual c++
    1923#ifdef _MSC_VER
    20  #include <stdio.h> //musi byc najpierw ten include zeby robic definy ponizej (albo bedzie '_vsnprintf': attributes inconsistent with previous declaration, stdio.h:358)
     24 #include <stdio.h> //this #include must be present before two #defines below can be used, otherwise one will see: '_vsnprintf': attributes inconsistent with previous declaration, stdio.h:358
    2125 #define vsnprintf _vsnprintf
    2226 #define snprintf _snprintf
     
    4852#ifdef LINUX
    4953 #include <strings.h>
    50  #define stricmp(a,b) strcasecmp(a,b)
    51  #define _isnan(a) isnan(a) //do nonstd_math.h?
     54 #ifndef __CYGWIN__
     55  #define stricmp(a,b) strcasecmp(a,b)
     56 #endif
    5257#ifdef INITIAL_DIR_IS_HOME
    5358 #include "cwd.h"
     
    7075#ifdef IPHONE
    7176 #include <string>
    72  #define _isnan(a) isnan(a) //do nonstd_math.h?
    7377 std::string getAppHome();
    7478 std::string getAppResources();
     
    7882
    7983#ifdef SHP
    80  //#define __assert_func(a,b,c,d) 0 //Currently, we are sorry to inform you that assert() is not yet supported. We have considered your request for internal discussion. No ale na szczêœcie w³asna (byle by by³a, bo i tak zak³adamy ze assert ktore przeciez dziala tylko w trybie debug nie jest potrzebne na bada) implementacja w "bada-assert.cpp"
    8184 #define GET_APP_HOME "/Home/"
    8285 #define GET_APP_RESOURCES "/Res/"
     
    100103
    101104
    102 #ifdef MAIN_FRAMSTICKS
    103  #define SCRIPTS_DIR GET_APP_RESOURCES "scripts" //katalogi sa na iphone std::string a gdzie indziej "const char*" i to sie wszedzie kompiluje?
    104 #endif
    105 
    106 
    107105
    108106//typedef unsigned char boolean; //niestety nie mozna uzyc 'bool' bo VC w rpcndr.h wlasnie tak definiuje booleana, jako unsigned char
  • cpp/frams/virtfile/virtfile.cpp

    r121 r123  
    5858int fread(void *ptr, size_t size, size_t nmemb, VirtFILE* f) {return f->Vread(ptr,size,nmemb);}
    5959int fwrite(const void *ptr, size_t size, size_t nmemb, VirtFILE* f) {return f->Vwrite(ptr,size,nmemb);}
     60
     61//for some systems, we need to #undef feof which is unfortunately defined as a macro... we have to #undef just to be able to define our own function with this name. Same in virtfile.h
     62#if defined __BORLANDC__ || defined _MSC_VER || defined __CYGWIN__ || defined SHP
     63 #undef feof
     64#endif
     65
     66int feof(VirtFILE* f) {return f->Veof();}
     67
     68//...and then restore the original macro:
    6069#ifdef __BORLANDC__
    61 #undef feof
     70 #define feof(__f)     ((__f)->flags & _F_EOF)
    6271#endif
    6372#ifdef _MSC_VER
    64 #undef feof
     73 #define feof(_stream)     ((_stream)->_flag & _IOEOF)
     74#endif
     75#ifdef __CYGWIN__
     76 #define feof(p)  __sfeof(p)
    6577#endif
    6678#ifdef SHP
    67 #undef feof
     79 restore original macro... if you ever want to compile this code on bada
    6880#endif
    69 int feof(VirtFILE* f) {return f->Veof();}
    70 #ifdef __BORLANDC__
    71 #define feof(__f)     ((__f)->flags & _F_EOF)
    72 #endif
    73 #ifdef _MSC_VER
    74 #define feof(_stream)     ((_stream)->_flag & _IOEOF)
    75 #endif
     81
    7682
    7783int fputc(int c,VirtFILE* f) {return f->Vputc(c);}
     
    95101int closedir(VirtDIR* d) {delete d; return 0;}
    96102dirent* readdir(VirtDIR* d) {return d->Vreaddir();}
     103
  • cpp/frams/virtfile/virtfile.h

    r121 r123  
    7070DLLEXP int fread(void *ptr, size_t size, size_t nmemb, VirtFILE* f);
    7171DLLEXP int fwrite(const void *ptr, size_t size, size_t nmemb, VirtFILE* f);
     72
     73
     74//for some systems, we need to #undef feof which is unfortunately defined as a macro... we have to #undef just to be able to define our own function with this name. Same in virtfile.cpp
     75#if defined __BORLANDC__ || defined _MSC_VER || defined __CYGWIN__ || defined SHP
     76 #undef feof
     77#endif
     78 
     79DLLEXP int feof(VirtFILE* f);// {return f->Veof();}
     80
     81//...and then restore the original macro:
    7282#ifdef __BORLANDC__
    73 #undef feof
     83 #define feof(__f)     ((__f)->flags & _F_EOF)
    7484#endif
    7585#ifdef _MSC_VER
    76 #undef feof
     86 #define feof(_stream)     ((_stream)->_flag & _IOEOF)
     87#endif
     88#ifdef __CYGWIN__
     89 #define feof(p)  __sfeof(p)
    7790#endif
    7891#ifdef SHP
    79 #undef feof //not sure if this is OK since feof() is not defined below for bada, but it won't compile without this #undef. Same in virtfile.cpp
     92 restore original macro... if you ever want to compile this code on bada
    8093#endif
    81 DLLEXP int feof(VirtFILE* f);// {return f->Veof();}
    82 #ifdef __BORLANDC__
    83 #define feof(__f)     ((__f)->flags & _F_EOF)
    84 #endif
    85 #ifdef _MSC_VER
    86 #define feof(_stream)     ((_stream)->_flag & _IOEOF)
    87 #endif
     94
    8895
    8996DLLEXP int fputc(int c,VirtFILE* f);
Note: See TracChangeset for help on using the changeset viewer.