By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

vc++ .NET 2005

sangeetha jagannathan
P: 23
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
Mar 12 '07 #1
Share this Question
Share on Google+
7 Replies


100+
P: 180
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/lib...04(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
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.
Expand|Select|Wrap|Line Numbers
  1. : warning C4996: 'fopen' was declared deprecated
  2. 1>        d:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : see declaration of 'fopen'
  3. 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.....
Mar 12 '07 #2

sangeetha jagannathan
P: 23
hi
thanks for ur reply.

the error i get is:

w:\tools\util\inflatable_filebuf.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
Mar 12 '07 #3

100+
P: 180
hi
thanks for ur reply.

the error i get is:

w:\tools\util\inflatable_filebuf.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.
Mar 12 '07 #4

100+
P: 180
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

Expand|Select|Wrap|Line Numbers
  1. PREVIOUS 
  2.  
  3. #include <fstream.hxx>                        
  4. #include <stdio.h>                             
  5. #include <fcntl.h>                             
  6. int main () {                                  
  7.     int fd;                                    
  8.     fd = open("t27.in",O_RDWR | O_CREAT, 0644); 
  9.     ifstream ifs;                              
  10.     ifs.attach(fd);                            
  11.     fd = creat("t28.out",0644);                
  12.     ofstream of;                                
  13.     of.attach(fd);                             
  14.     return 0;                                  
  15.  
  16.  
  17. To: 
  18. NEW
  19.  
  20. #include <fstream> 
  21. int main () { 
  22.     ifstream ifs("t27.in", ios::in | ios::out); 
  23.     ofstream ofs("t28.out"); 
  24.     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.
Mar 12 '07 #5

sangeetha jagannathan
P: 23
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
Mar 12 '07 #6

sangeetha jagannathan
P: 23
hi

i will give a sample of my problem

consider this .h and .cpp file

a.cpp

#include "Inflatable_filebuf.h"

Inflatable_filebuf::Inflatable_filebuf(void)
{
}

Inflatable_filebuf::~Inflatable_filebuf(void)
{
}

streambuf* Inflatable_filebuf::setbuf(char* p , int len)
{
if (is_open() && base())
return 0 ;
return 0;
}

int main () {
return 0;
}


Inflatable_filebuf.h

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

class Inflatable_filebuf : public filebuf
{
public:
Inflatable_filebuf(void);
virtual streambuf* setbuf(char* p, int len);
public:
~Inflatable_filebuf(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
Mar 12 '07 #7

100+
P: 180
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.microsoft.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!!!
Mar 12 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.