Ignore:
Timestamp:
02/11/14 00:01:21 (9 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.h

    r123 r131  
    7272
    7373
    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
     74//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.cpp
     75#if defined _MSC_VER || defined __CYGWIN__ || defined SHP
     76 #pragma push_macro("feof")
     77 #undef feof
     78#endif
     79#if defined __BORLANDC__ //does not support #pragma push_macro/pop_macro
    7680 #undef feof
    7781#endif
     
    8084
    8185//...and then restore the original macro:
     86#if defined _MSC_VER || defined __CYGWIN__ || defined SHP
     87 #pragma pop_macro("feof")
     88#endif
    8289#ifdef __BORLANDC__
    8390 #define feof(__f)     ((__f)->flags & _F_EOF)
    84 #endif
    85 #ifdef _MSC_VER
    86  #define feof(_stream)     ((_stream)->_flag & _IOEOF)
    87 #endif
    88 #ifdef __CYGWIN__
    89  #define feof(p)  __sfeof(p)
    90 #endif
    91 #ifdef SHP
    92  restore original macro... if you ever want to compile this code on bada
    9391#endif
    9492
Note: See TracChangeset for help on using the changeset viewer.