Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Close() / write() was not declared in this scope
QtWS25 Last Chance

Close() / write() was not declared in this scope

Scheduled Pinned Locked Moved C++ Gurus
7 Posts 3 Posters 18.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vkonstantinov
    wrote on 8 Dec 2011, 11:27 last edited by
    #1

    Find the code below. What i am doing wrong. The similar code works in plain GCC compliling. Brings the error close() was not declared in this scope. The same for write() . open() is Ok.

    @#ifndef KSEG_DH
    #define KSEG_DH

    #include "QtGlobal"
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sys/param.h>
    #include <sys/ioctl.h>
    #include <sys/types.h>
    #include </usr/include/sys/io.h>
    #include <sys/stat.h>
    #include <sys/errno.h>
    #include </usr/include/sys/fcntl.h>
    #include </usr/include/linux/mtio.h>
    .....
    #include "KSEG_D.h"
    .....
    int KSEG_D::CloseOutTape()
    {
    close( idOutTape );
    return 0;
    }@

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 8 Dec 2011, 11:31 last edited by
      #2

      Do you mind to enlighten us and tell us the tool chain where the compile fails?

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vkonstantinov
        wrote on 8 Dec 2011, 11:40 last edited by
        #3

        Exactly.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on 8 Dec 2011, 17:07 last edited by
          #4

          @#include </usr/include/sys/io.h>@

          is not a good idea:-) The compiler checks all the include pathes for the files you give and /usr/include is in the list of include pathes on any decent unix-based system. sys/types.h is already found and most likely located right next to sys/io.h.

          Are you planing on asking here about each and every method you need to include somewhere? You were the guy that asked about ioctl before, aren't you? Please check the documentation of the methods you use for the include files needed (or check /usr/include manually, or read a book, or check the working non-Qt code you have).

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vkonstantinov
            wrote on 9 Dec 2011, 08:44 last edited by
            #5

            Thank you. You are so kind. I never asked if i am not sure that i tryed everything i can find out. Some people not so smart and need help

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on 12 Dec 2011, 10:07 last edited by
              #6

              Ok, sorry if I was patronizing, but your question led me to believe that you did none of the following:

              check the documentation, e.g. by doing "man 2 close" to get the man page (assuming you are on a unix-oid OS, going by you including /usr/include)?

              check a book on C programming. close/open/write/read are pretty well described in any of them. C++ books on the other hand tend to not cover them to extensively since C++ provides more high level directives for file handling. Qt has some even more high level classes for that, too.

              google for "close function in linux"? That gets you the man page as the first hit.

              run "grep write /usr/include"? That will get you lots of hits, so that is most likely not the preferred way to go;-)

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vkonstantinov
                wrote on 18 Dec 2011, 04:44 last edited by
                #7

                Thank you. I was out of the office, so can not reply promptly. The problem solved. Brief description:

                1. I could not find ioctl.h. It was really stupid error – I was testing the application on Widows platform that is not proper for ioctl
                2. The error aroused during compilation as close() ( read(), write() ) is not defined. In Linux to use this in *.cpp mtio.h needs to be included.
                1 Reply Last reply
                0

                6/7

                12 Dec 2011, 10:07

                • Login

                • Login or register to search.
                6 out of 7
                • First post
                  6/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved