Thread: Hardware IO in linux

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I am a fan of C file streams over C++, so that would be my way to go. But I am not the OP so perhaps....

    Example:
    Code:
    fstream *printer(mode_t perm)
    {
    #ifdef ELYSIA
      fstream *f = NULL;
    #else
      fstream *f = 0;
    #endif
    
      int fd = open("/dev/parport0", O_RDWR, perm);
    
      // do whatever you need to do....
    
      try
      {
        f = new fstream(fd);
      } catch(std::exception e)
      {
        close(fd);
        abort();
      }
    
      return f;
    }

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by master5001 View Post
    Code:
    ..
    #ifdef ELYSIA
      fstream *f = NULL;
    #else
      fstream *f = 0;
    #endif
    ...
    LOL and feel a bit worried I understood the joke...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing a linux hardware driver
    By nexusone in forum Linux Programming
    Replies: 1
    Last Post: 08-12-2008, 07:33 PM
  2. Why Linux, for the average user?
    By Hunter2 in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 07-07-2006, 02:36 PM
  3. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM
  4. Linux Hardware Handbook
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 04-02-2002, 06:06 AM