C fdopen with and without -ansi

Login or Register to Reply

Thread Tools Search this Thread
# 8  
Old 10-18-2018
#define _XOPEN_SOURCE 1
#include <stdio.h>  
#include <stdlib.h>   

FILE * my_tester (char * fname, int pnum) 
  int fd;   
  FILE * fp;      
    sprintf (fname, "/tmp/PRS.%05i.XXXXXX", pnum);         
    fd = mkstemp (fname);     
    if (fd <0) 
         return (NULL); 
    if ((fp = fdopen (fd, "w")) == NULL)     
        return (NULL);     
     return (fp); 

Last edited by RudiC; 10-18-2018 at 04:56 AM..
# 9  
Old 10-18-2018
Note that defining the feature test macro _xopen_source to have the value 1 as done by the following line in dodona's code in post #5 (and later duplicated in HongThai's code in post #8) as shown below:
#define  _XOPEN_SOURCE  1

without defining any other feature test macros asks for a programming environment that conforms to the interfaces as defined by The X/Open Portability Guide, Issue 3 (which was published in 1988). The only systems that I'm aware of that still support this programming environment are Solaris/SunOS systems distributed by Sun, Oracle, and Fujitsu.

The feature test macro I suggested in post #3 requests a much more commonly available programming environment.
Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
why the implementatoin of Bakery algorithm in ANSI C does not work in ANSI C sehang Programming 2 08-25-2010 03:06 PM
Linux to ansi pc conversion Tuxidow Shell Programming and Scripting 0 03-09-2010 04:26 AM
Question about strings in ansi C brinch Programming 3 01-29-2010 11:47 AM
HP-UX ansi c precompiler yoavbe HP-UX 3 09-01-2009 11:37 AM
Unix_ANSI to PC-ANSI ssmallya HP-UX 0 02-06-2008 02:12 AM
Convert file from Unix - ANSI to PC - ANSI ssmallya Shell Programming and Scripting 0 02-05-2008 05:07 AM
hint on ansi c dhaval chevli Programming 2 06-15-2006 03:40 AM
ANSI / C Compiler for HP-UX 11.11 shawnbishop HP-UX 3 03-28-2006 05:53 PM
ANSI C compiler on UNIX elenav UNIX for Dummies Questions & Answers 1 03-14-2005 08:35 PM
ansi problem Lewis HP-UX 0 05-13-2004 12:39 PM
difference between fdopen() and freopen() kinnaree Programming 1 12-02-2002 11:02 AM
ANSI C vs POSIX bb00y Programming 2 11-05-2002 08:20 AM
struct timespec in ANSI C trido Programming 3 10-29-2002 05:59 AM
Ansi C Frankie Programming 4 11-23-2001 08:55 AM
K&R vs. ANSI REM Programming 1 06-08-2001 11:20 AM