Bug 51811 - compiler can't find ptsname function
Summary: compiler can't find ptsname function
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: i386
OS: Linux
high
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-08-15 14:28 UTC by Keith Ansell
Modified: 2007-03-27 03:48 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2001-08-22 14:51:49 UTC
Embargoed:


Attachments (Terms of Use)

Description Keith Ansell 2001-08-15 14:28:06 UTC
Description of Problem:
gcc 2.96 shipped with RedHat 7.1 does not recognize the "ptsname" function that worked OK on RedHat 7.0 & 6.2.

Version-Release number of selected component (if applicable):
gcc 2.96 on RedHat 7.1

How Reproducible:
Every time with sample program below.

Steps to Reproduce:
1. Compile the program called "t" with "g++ -w -O0 t.C -o $1 -ldl -lcrypt -lcurses"
2. 
3. 

Actual Results:
t.C: In function `int main ()':
t.C:10: `ptsname' undeclared (first use this function)
t.C:10: (Each undeclared identifier is reported only once for each
function it appears in.)  

Expected Results:


Additional Information:

Sample program "t":
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <stdlib.h>

int main (void) {
   char *SlaveDevice;
   int MasterPseudoFid = 0;
   cerr << "Hello - World " << endl;
   SlaveDevice = (char *)ptsname(MasterPseudoFid);
   return 0;
}

Comment 1 Jakub Jelinek 2001-08-17 13:50:15 UTC
You get ptsname prototype only if you request some standard which has this
function. Particularly, you can use -D_XOPEN_SOURCE or -D_GNU_SOURCE.

Comment 2 Keith Ansell 2001-08-22 13:58:48 UTC
This works well in the test software, but when it is added to my applications
main makefile the program now shows errors on the following software.


     With -D_GNU_SOURCE and -D_XOPEN_SOURCE signal.h:36: declaration of `void
(*sigset (int,void(*) int()))  (int) throw()' throws different exceptions
      problems with sigignore, and stdlib.h grantpt and unlockpt.


Can You Help?


Thanks
         Keith Ansell



Comment 3 Jakub Jelinek 2001-08-22 14:04:34 UTC
Generally you should not prototype things which are prototyped in system headers.

Comment 4 Keith Ansell 2001-08-22 14:13:54 UTC
Agreed, then why can't I compile my source on this version of REDHAT and GNU
where as the same program compiles on RH5.x RH6.x and RH7.0. I can supply you 
with a copy of the program, if you wish? but the answer to the BUG is NOT 
-D_XOPEN_SOURCE or -D_GNU_SOURCE.

Regards
Keith Ansell


Comment 5 Jakub Jelinek 2001-08-22 14:51:45 UTC
It is enough if you just supply preprocessed source of the file which fails
(e.g. use -save-temps option of g++ which will create an .ii file), I can
tell you what's wrong.
But having ptsname protected with _XOPEN_SOURCE or _GNU_SOURCE is nothing new,
e.g. glibc in 6.2 had it too.

Comment 6 Jakub Jelinek 2001-08-22 15:22:06 UTC
I'd suggest using -D_GNU_SOURCE, removing grantpt and unlockpt prototypes
from Communications.h and at least kill sigrelse, sigignore, sighold
and sigset in your signal.h. Portable applications cannot do what these
headers do.


Note You need to log in before you can comment on or make changes to this bug.