This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ../../gcc/cppfiles.c:823: size of array `intermed' has non-integer type


> Using fpathconf may be dangerous.  The Solaris documentation sez:
> 
>      6    If path or fildes refers to a pipe or FIFO,  the  value
>           returned  applies  to  the  pipe  or  FIFO.  If path or
>           fildes  refers  to  a  directory,  the  value  returned
>           applies  to  any  FIFOs  that  exist  or can be created
>           within the directory.  If path or fildes refer  to  any
>           other type of file, the behavior is undefined.
> 
> In particular, we may get garbage if we call it on a regular file.  I
> have to think about this some more.

The hpux9.01 documentation is identical.  You would only want to
use fpathconf if desc refers to a pipe or FIFO.  If it refers to
a regular file, you can choose whatever size you want for the read
buffer.  The test can be done with a fstat call and the S_ISFIFO
macro.  However, it may be hard to come up with a universal way
of doing this.  For example, hpux9.01 requires _INCLUDE_POSIX_SOURCE
be defined before the S_ISFIFO macro is defined.

Another approach that I have used in the past is to just issue reads
until you get the desired number of bytes in the buffer.

Dave

-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]