delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/06/23/02:00:14

From: wozzle!alane AT imageek DOT york DOT cuny DOT edu
Subject: Re: MORE on O_TEXT/O_BINARY
To: imageek!src4src!imageek!wozzle!imageek!sdsp.mc.xerox.com!leisner (Marty Leisner)
Date: Wed, 22 Jun 1994 19:15:04 -0400 (EDT)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

> Well, I've learned"
> 	fopen("b") is ANSI
> 	open(O_BINARY) is not POSIX...
> 
> Recompiling the gnu fileutils, I needed to stick this
> in the fileutils lib (or else have to change every open call
> everywhere or change __fmode in each main...):
> 
[ code elided ]

You could also declare a global object thus:

class FModeFixer {
	FModeFixer(int m) { _fmode = m; }
};

FModeFixer _fmodefixer(O_BINARY);

which will of course get called before main if you just make
sure it gets linked in by putting it into some essential .o file.

This avoids changing the library.

I used this approach (at DJ's suggestion) to initialize the gppconio
library many moons ago.

-- 
J. Alan Eldridge (alane AT wozzle DOT linet DOT org)


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019