🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3431

Why do I get warnings using popen in g++??? Help needed!

#3431
From: Zhenbin (Kevin) Xu
Date: Mon, 16 Mar 1998 00:00
80 lines
3080 bytes
>Sun OS 5.5
>g++  version unknown, probably very old (1993???)
>
>First of all, my program complied without any warning in my Linux box.
>However, not in this Sun box...
>
>I got the following warnings:
>    msgqueue.cpp: In function `int DoServer()':
>    msgqueue.cpp:190: warning: implicit declaration of function `int
>popen(...)'
>    msgqueue.cpp:190: warning: initialization to `FILE *' from `int' lacks
a
>cast
>    msgqueue.cpp:192: warning: implicit declaration of function `int
>pclose(...)'
>
>Here is the context:
>  if( strlen(msgpackage.mtext) > 0 )
>  {
>    #ifdef _MYDEBUG
>       cout << "Server: rcv: " << msgpackage.mtext << endl;
>    #endif
>       char cmdLine[MSGBUFSIZE+24];
>       sprintf(cmdLine,"%s%s",cmdPing,msgpackage.mtext);
>+     FILE* fp=popen(cmdLine,"r");
>+     int iStatus=0;
>+     switch( pclose(fp) ) // pclose returns the termination status of
>cmdLine
>       {
>       case 0:
>        iStatus = HOST_ALIVE;
>        break;
>       default:
>        iStatus = HOST_DEAD;
>       }
>       sprintf( msgpackage.mtext +
>strlen(msgpackage.mtext),"\t%s",STR_HOST_STATUS[iStatus] );
>       msgpackage.mtype = SERVER_DATA;
>       msgsnd( msg_id, (MSGStruct)&msgpackage, MSGBUFSIZE, 0);
>      }
>
>It seems very clear that the "popen" and "pclose" are not declared in the
>header file. However, they suppose to be declared in stdio.h and here is my
>includes:
>    #include <sys/types.h>
>    #include <sys/ipc.h>
>    #include <sys/msg.h>
>    #include <limits.h>
>    #include <unistd.h>
>    #include <syslog.h>
>    #include <errno.h>
>    #include <string.h>
>    #include <stdio.h>
>    #include <stdlib.h>
>    #include <fstream.h>
>    #include <iostream.h>
>
>I suspect that this is because that I primarily use C++ functions and there
>are some preprocess symbols need to be declared/cleared.  If it is the
case,
>how can I use popen in my C++ program in SUN OS with a probably obsoleted
>g++ version???
>
>Once again, there is no any syntax and logical error when I run this
program
>on my Linux machine. However, I need it to be able to run on that stupid
Sun
>box as well - and worst of all, I am primary a Windows programmer.
>
>Any information will be very much appreciated! Please also reply to my
>account at kevin@blueshoe.com .
>
>Thanks in advance,
>Kevin
>
>
>
>
>
Technical Details
Message-ID: <6ejp15$5ja@bgtnsc03.worldnet.att.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8c9b,d6189dc8a4f3b3f5,start
X-Google-Attributes: gidf8c9b,public
X-Google-Thread: fc89c,d6189dc8a4f3b3f5,start
X-Google-Attributes: gidfc89c,public
X-Google-Thread: 10ba33,d6189dc8a4f3b3f5,start
X-Google-Attributes: gid10ba33,public
From: "Zhenbin (Kevin) Xu" <zbxu@worldnet.att.net>
Subject: Why do I get warnings using popen in g++??? Help needed!
Date: 1998/03/16
Message-ID: <6ejp15$5ja@bgtnsc03.worldnet.att.net>
X-Deja-AN: 334609662
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Organization: AT&T WorldNet Services
Newsgroups: comp.unix.programmer,comp.unix.questions,gnu.g++.help