Is there any difference between C and C++ pipes implementation? Is there any C++ library that makes using pipes easier? I ask those questions because there are many 'wrapper' classes in C++ that wraps C (like string, vector etc.) Is there anything that 'wraps' pipes?
<Thanks>

Recommended Answers

All 5 Replies

Pipes are part of the POSIX operating system, and nothing to do with the language.

As for classes, maybe - I dunno.
I've reached my google quota for the day.

pipes don't work at all in win32 programs, only console programs on Ms-Windows platforms. See the discussion here for work-around.

> Is there anything that 'wraps' pipes?
i do not know of any, but it is very easy to roll out one of our own. eg.

#include <stdio.h>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <fstream>
#include <iostream>
using namespace boost::iostreams ;

struct opipestream : stream< file_descriptor_sink >
{
  typedef stream< file_descriptor_sink > base ;
  explicit opipestream( const char* command )
    : base( fileno( pipe = popen( command, "w" ) ) ) {}
  ~opipestream() { close() ; pclose( pipe ) ; }
  private : FILE* pipe ;
};

int main()
{
  std::cout << "#includes in this file:" << std::flush ;
  std::ifstream fin( __FILE__ ) ;
  opipestream pout( "grep '^#include' | wc -l" ) ;
  pout << fin.rdbuf() ;
}

// link with libboost_iostreams  eg.
// g++ -Wall -std=c++98 -pedantic -I /usr/local/include -L /usr/local/lib -lboost_iostreams myfile.cc

So... is there anything built into the language (C++) that allows communicating between processes? I can't imagine how it would be done as operating system controls processes, but... is there?

It still depends on what OS you're using, so the answer would be: no, c++ does not have anything standard for that

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.