From: Jim W. <jwa...@ph...> - 2006-11-15 01:57:18
|
Daniel M. German wrote: > Jim and I were originally discussing that htons is > difficult to include (due to compilation dependencies) under Windows. > We then started discussing WRITESHORT. See below. > > WRITESHORT, does not return a value. In fact, it can't be used in an expression: > > #define WRITESHORT( theShort ) svar = theShort; d = data; SHORTNUMBER( svar, d ); \ > count = 2; mywrite (fnum,count,data); > > If the ; are replaced with , it could be. > > Now, mywrite is used for OS 9 compatiblity. That should be removed. A > better macro would be: > Isn't FSWrite used for other Mac OS? I don't see we can remove mywrite. > #define WRITESHORT( theShort ) (svar = theShort, d = data; SHORTNUMBER( svar, d ), \ > count = 2, write(fnum,count,data) == count) > > returns TRUE if it succeeds and returns false if it does not. All the > PSD logic should be improved for error handling and this would be a > first step. > > The macros have a disadvantage: they depend on local variables being > created in the local space. It is a tradeoff for speed. But I don't > think they add that much in terms of speed. > > what do you think? > This should work with for both Mac and Win. #define WRITESHORT( theShort ) (svar = theShort, d = data; SHORTNUMBER( svar, d ), \ count = 2, mywrite(fnum, count, data), 2 == count) -- Jim Watters Yahoo ID: j1vvy ymsgr:sendIM?j1vvy jwatters @ photocreations . ca http://photocreations.ca |