gcc -U_WIN32 pitfalls!
Mumit Khan
khan@xraylith.wisc.edu
Fri Apr 23 19:33:00 GMT 1999
Just for kicks, I tried to build a small analysis program with -U_WIN32;
this tool is essentially a filter and doesn't use any win32 specific
features, so it should be pretty safe, right?
Looks like certain typedefs are *WRONG* when you undefine _WIN32 and it
causes amazingly subtle bugs! Any code using stat for example will be
subtly but surely broken.
I'm attaching a small trivial program that should illustrate this. Here's
the header comments from the file.
This is with stock B20.1. Compiler version is no relevant here.
//
// A simple program to show the pitfall of using -U_WIN32 in your code
// under Cygwin b20.1!
//
// To build:
// $ c++ -U_WIN32 -o cyg-stat-bug cyg-stat.cc
// $ c++ -o cyg-stat-ok cyg-stat.cc
//
// Now run it giving a filename on command line:
//
// $ ./cyg-stat-bug ./cyg-stat.cc
// $ ./cyg-stat-ok ./cyg-stat.cc
//
// To find the cause of the problem (after you notice it in the output
// of course!), you need to look at the preprocessed files.
//
// $ c++ -save-temps -U_WIN32 -o cyg-stat-bug cyg-stat.cc
// $ mv cyg-stat.ii cyg-stat-bug.ii
// $ c++ -save-temps -o cyg-stat-ok cyg-stat.cc
// $ mv cyg-stat.ii cyg-stat-ok.ii
// $ diff -u3p cyg-stat-bug.ii cyg-stat-ok.ii
//
// Look for ino_t.
//
Regards,
Mumit
More information about the Cygwin
mailing list