Ignore:
Timestamp:
02/11/14 00:01:21 (11 years ago)
Author:
Maciej Komosinski
Message:

a better way to save/restore a preprocessor macro, unfortunately not a c++ standard (yet?)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/virtfile/virtfile.cpp

    r123 r131  
    5959int fwrite(const void *ptr, size_t size, size_t nmemb, VirtFILE* f) {return f->Vwrite(ptr,size,nmemb);}
    6060
    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
     61
     62//since we want our own feof(VirtFILE*) function and some systems unfortunately define feof as a macro, we need to #undef it. Same as in virtfile.h
     63#if defined _MSC_VER || defined __CYGWIN__ || defined SHP
     64 #pragma push_macro("feof")
     65 #undef feof
     66#endif
     67#if defined __BORLANDC__ //does not support #pragma push_macro/pop_macro
    6368 #undef feof
    6469#endif
     
    6772
    6873//...and then restore the original macro:
     74#if defined _MSC_VER || defined __CYGWIN__ || defined SHP
     75 #pragma pop_macro("feof")
     76#endif
    6977#ifdef __BORLANDC__
    7078 #define feof(__f)     ((__f)->flags & _F_EOF)
    71 #endif
    72 #ifdef _MSC_VER
    73  #define feof(_stream)     ((_stream)->_flag & _IOEOF)
    74 #endif
    75 #ifdef __CYGWIN__
    76  #define feof(p)  __sfeof(p)
    77 #endif
    78 #ifdef SHP
    79  restore original macro... if you ever want to compile this code on bada
    8079#endif
    8180
Note: See TracChangeset for help on using the changeset viewer.