This is a follow-up regarding an issue I've had using ofstream in a cross-platform app (I started an earlier thread but I prematurely marked it as 'resolved')

For creating an ofstream (in posix) we have some openmode enums looking something like this:-

Code:
enum openmode
{
	in,
	out,
	ate,
	app,
	trunc,
	bin
};
They get declared in a namespace (or possibly a class) called ios. Microsoft uses something similar- but for MSVC the equivalent enums would be these:-

Code:
enum openmode
{
	in,
	out,
	ate,
	app,
	trunc,
	binary  // <--- Note that this one is different !!
};
So for a cross platform app (which might need to open files in binary mode) I'd need stuff like this all over the place:-

Code:
#ifdef _MSC_VER
      ofstream whatever ("wherever", ios::binary);
#else
      ofstream whatever ("wherever", ios::bin);
#endif
which is obviously a bit messy! I can (kinda) resolve it with a suitable #define:-

Code:
#ifdef _MSC_VER
     #define bin binary
#endif
but that's also messy because now, any use of the word bin will get changed to binary. Ideally I'd like to do this:-

Code:
#ifdef _MSC_VER
     #define ios::bin ios::binary
#endif
but that gets rejected by the compiler... Is there any clever way to set this up such that all occurrences of ios::bin will get changed to ios::binary - but any other occurrences of bin would be unaffected?