autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Portability of fopen (foo, "wb") (Was: bug in AC_COMPUTE_INT)


From: John W. Eaton
Subject: Re: Portability of fopen (foo, "wb") (Was: bug in AC_COMPUTE_INT)
Date: Thu, 16 Nov 2000 10:05:13 -0600

On 16-Nov-2000, Earnie Boyd <address@hidden> wrote:

| --- Akim Demaille <address@hidden> wrote:
|
| > Does anybody know whether using fopen (foo, "wb") is portable?  Gary
| > uses a test for this, but I don't know if it's really needed.  A grep
| > on the packages I have at hand show this:
| 
| I'm really interested in this answer myself.  Lars' patch is the
| correct one if it is.

I no longer have any old/odd systems to use for testing, so the next
best thing for me is to check my copy of Mark R. Horton's "Portable C
Software", published in 1990.  In the entry for fopen, it says: 

  If you intend the file to be a binary file, the call won't be as
  portable.  [...]  For other operating systems, it's common to add
  another character to the second argument, such as b, to indicate a
  binary file. [...]

  Unfortunately, the second argument for binary files is not very
  portable yet.  It is part of ANSI C, but wasn't previously
  implemented widely.  [...]

  [...]

  Another approach is to always include the trailing b anyway.  Most
  implementations that don't look for it will ignore it.  Whie this
  isn't guaranteed to work all the time, in practice, it may be a
  pragmatic and relatively elegant solution.

So, after all this time, maybe it doesn't matter all that much.

But for the particular case that started this discussion, isn't
autoconf writing ASCII data to a text file?  Should that really
require binary mode, or is there something fishy with the setup of the
cygwin system that caused the problem?

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]