vc++ .NET 2005

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sangeetha jagannathan
    New Member
    • Jan 2007
    • 22

    vc++ .NET 2005

    i have some problem with some of the functions, the details are below.

    in vc6, in stream.h we have the following functions
    setb()
    base()
    ebuf()
    unbuffered()
    allocate()
    out_waiting

    in fstream.h we hv fd()

    my code uses all these functions, now this particular link below says that these functions are removed from vc8
    http://msdn2.microsoft .com/en-us/library/8h8eh904(vs.80) .aspx

    now is there any alternative function defined in vc8 to replace the older functions?

    i will be greatful to any suggesstions you give

    thanks in advance
    sangeetha
  • vermarajeev
    New Member
    • Aug 2006
    • 180

    #2
    Originally posted by sangeetha jagannathan
    i have some problem with some of the functions, the details are below.

    in vc6, in stream.h we have the following functions
    setb()
    base()
    ebuf()
    unbuffered()
    allocate()
    out_waiting

    in fstream.h we hv fd()

    my code uses all these functions, now this particular link below says that these functions are removed from vc8


    now is there any alternative function defined in vc8 to replace the older functions?

    i will be greatful to any suggesstions you give

    thanks in advance
    sangeetha
    You wont get any errors when you use those functions but infact some warnings.

    When you complie your code, you will get some warnings. Read those, it may read something like this.
    Code:
    : warning C4996: 'fopen' was declared deprecated
    1>        d:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : see declaration of 'fopen'
    1>        Message: 'This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
    I used fopen in my program which is now deprecated in newer version. So microsoft suggest to use fopen_s.....

    Comment

    • sangeetha jagannathan
      New Member
      • Jan 2007
      • 22

      #3
      hi
      thanks for ur reply.

      the error i get is:

      w:\tools\util\i nflatable_fileb uf.c(239) : error C3861: 'fd': identifier not found

      since i used to get this error for all the functions, i just gave a declaration for these functions. it worked, it got conppiled. BUT now wen i try to do the regression test these functions give error. regression test doesnt pass.

      it gives error saying "identifier not found"

      my teammate suggesst me to write the definition for these function, but i dunno to write , i dunno for wat purpose these functions are used for.

      try to find an alternative to these functions or a function definition for these functions.

      thanking you
      sangeetha

      Comment

      • vermarajeev
        New Member
        • Aug 2006
        • 180

        #4
        Originally posted by sangeetha jagannathan
        hi
        thanks for ur reply.

        the error i get is:

        w:\tools\util\i nflatable_fileb uf.c(239) : error C3861: 'fd': identifier not found

        since i used to get this error for all the functions, i just gave a declaration for these functions. it worked, it got conppiled. BUT now wen i try to do the regression test these functions give error. regression test doesnt pass.

        it gives error saying "identifier not found"

        my teammate suggesst me to write the definition for these function, but i dunno to write , i dunno for wat purpose these functions are used for.

        try to find an alternative to these functions or a function definition for these functions.

        thanking you
        sangeetha
        Can you please post some part of your codes. If the project is big just send a snippet of code where the error occurs.

        Comment

        • vermarajeev
          New Member
          • Aug 2006
          • 180

          #5
          Originally posted by vermarajeev
          Can you please post some part of your codes. If the project is big just send a snippet of code where the error occurs.
          I got to know your problem. Actually you are using an older version of library. There is no need to write any seperate function as your teammates suggested but you can use the new library ie. fstream defined in std namespace. Here is a sample program which can give you some idea about how to do that.


          Here is a sample program

          CONVERT this code

          Code:
          PREVIOUS 
          
          #include <fstream.hxx>                        
          #include <stdio.h>                             
          #include <fcntl.h>                             
          int main () {                                  
              int fd;                                    
              fd = open("t27.in",O_RDWR | O_CREAT, 0644); 
              ifstream ifs;                              
              ifs.attach(fd);                            
              fd = creat("t28.out",0644);                
              ofstream of;                                
              of.attach(fd);                             
              return 0;                                  
          } 
          
          
          To: 
          NEW
          
          #include <fstream> 
          int main () { 
              ifstream ifs("t27.in", ios::in | ios::out); 
              ofstream ofs("t28.out"); 
              return 0; 
          }
          Compare previous and new version above. The life is easier in newer version. If you still want to use older library, you need to do some settings for that. Just google to find a solution. I suggest you to use new library. It will be helpful for future.

          Comment

          • sangeetha jagannathan
            New Member
            • Jan 2007
            • 22

            #6
            hi
            actually i am not suppose to send the code according to company policy.
            if you see the link that i sent you, u will get the real picture of all the function.
            meanwhile i will try to create a similar project like that of mine and send you.

            thanking you
            sangeetha

            Comment

            • sangeetha jagannathan
              New Member
              • Jan 2007
              • 22

              #7
              hi

              i will give a sample of my problem

              consider this .h and .cpp file

              a.cpp

              #include "Inflatable_fil ebuf.h"

              Inflatable_file buf::Inflatable _filebuf(void)
              {
              }

              Inflatable_file buf::~Inflatabl e_filebuf(void)
              {
              }

              streambuf* Inflatable_file buf::setbuf(cha r* p , int len)
              {
              if (is_open() && base())
              return 0 ;
              return 0;
              }

              int main () {
              return 0;
              }


              Inflatable_file buf.h

              #include <fstream>
              #include <iostream>
              using namespace std;

              class Inflatable_file buf : public filebuf
              {
              public:
              Inflatable_file buf(void);
              virtual streambuf* setbuf(char* p, int len);
              public:
              ~Inflatable_fil ebuf(void);
              };


              here we are using fstream and using the base class filebuf and also using the function base(), it gives this error when compiled on vc8

              " base() identifier not found"


              the same project when compiled on vc6 by changing fstream to fstream.h and iostream to iostream.h . and not using the namespace, gets compiled


              the below link says that these functions have been removed from vc8

              http://msdn2.microsoft .com/en-us/library/8h8eh904(vs.80) .aspx


              The same type of error occurs for the following functions also

              setb()
              base()
              ebuf()
              unbuffered()
              allocate()
              out_waiting


              so how to solve this problem, is there any alternative function defined in vc8 for these functions.


              thanks in advance
              sangeetha

              Comment

              • vermarajeev
                New Member
                • Aug 2006
                • 180

                #8
                From my understanding you are working on a kind of maintenance project. You need to port that project to the latest library. If I'm correct then just type "The old iostream library" on your google and you get many links about how to port to new library.

                Here is one link i came through "http://support.microso ft.com/kb/154419".

                What I can suggest is first understand what are the differences between old and new library. Then what was the basic functionality of functions used in old library, then find an alternative to that in new library.

                Just see the above sample program in previous post and see how attach function which was used in older library is replaced with new library.

                Best of luck!!!

                Comment

                Working...