Home Man
Search
Today's Posts
Register

Post questions about C, C++, Java, SQL, and other programming languages here.

C fdopen with and without -ansi

Tags
-a, ansi, fdopen -ansi, programming

Login to Reply

 
Thread Tools Search this Thread
# 8  
Old 5 Days Ago
Code:
#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; 5 Days Ago at 04:56 AM..
# 9  
Old 4 Days Ago
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:
Code:
#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 to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
why the implementatoin of Bakery algorithm in ANSI C does not work in ANSI C sehang Programming 2 08-25-2010 03:06 PM
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
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
Ansi C Frankie Programming 4 11-23-2001 08:55 AM
K&R vs. ANSI REM Programming 1 06-08-2001 11:20 AM


All times are GMT -4. The time now is 07:52 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password