473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

is it a bug in gcc2.3.2?

the following code cannot pass the compiler:

#include <fstream>
#include <iostream>

using namespace std;

int main()
{
fstream outfile("i:\\test.txt", ios_base::in | ios_base::out);
long lFlag = outfile.flags();

outfile.setf(ios_base::app);
cout << hex << "Original flag : " << lFlag << '\n'
<< "Now flag : " << outfile.flags() << '\n';

if (outfile.flags() & ios_base::app)
cout << "append bit set!\n";

char ch;
while (cin >> ch)
outfile << ch;

cout << '\n';
outfile.seekg(0);
while (outfile.get(ch))
cout << ch;
cout << '\n';

return 0;
}

the compiler returns the errors:

test3.cpp: In function `int main()':
test3.cpp:11: no matching function for call to
`std::basic_fstream<char,
std::char_traits<char> >::setf(const std::_Ios_Openmode&)'
i:/mingw/include/c++/3.2/bits/ios_base.h:342: candidates are:
std::_Ios_Fmtflags std::ios_base::setf(std::_Ios_Fmtflags)
i:/mingw/include/c++/3.2/bits/ios_base.h:350:
std::_Ios_Fmtflags std::ios_base::setf(std::_Ios_Fmtflags,
std::_Ios_Fmtflags)

but there is no problem with both bcc5.5 and vc6.0.

my system is Windows2000 and i use the gcc2.3.2 shipped with
mingw2.0.3.

what's the matter with gcc2.3.2 or my program?
Jul 19 '05 #1
1 1873

"gukn9700" <gu******@hotmail.com> wrote in message
news:5g********************************@4ax.com...
the following code cannot pass the compiler:

#include <fstream>
#include <iostream>

using namespace std;

int main()
{
fstream outfile("i:\\test.txt", ios_base::in | ios_base::out);
long lFlag = outfile.flags();

outfile.setf(ios_base::app);
cout << hex << "Original flag : " << lFlag << '\n'
<< "Now flag : " << outfile.flags() << '\n';

if (outfile.flags() & ios_base::app)
cout << "append bit set!\n";

char ch;
while (cin >> ch)
outfile << ch;

cout << '\n';
outfile.seekg(0);
while (outfile.get(ch))
cout << ch;
cout << '\n';

return 0;
}

the compiler returns the errors:

test3.cpp: In function `int main()':
test3.cpp:11: no matching function for call to
`std::basic_fstream<char,
std::char_traits<char> >::setf(const std::_Ios_Openmode&)'
i:/mingw/include/c++/3.2/bits/ios_base.h:342: candidates are:
std::_Ios_Fmtflags std::ios_base::setf(std::_Ios_Fmtflags)
i:/mingw/include/c++/3.2/bits/ios_base.h:350:
std::_Ios_Fmtflags std::ios_base::setf(std::_Ios_Fmtflags,
std::_Ios_Fmtflags)

but there is no problem with both bcc5.5 and vc6.0.

my system is Windows2000 and i use the gcc2.3.2 shipped with
mingw2.0.3.

what's the matter with gcc2.3.2 or my program?


Your program of course. setf is for format flags, ios_base::app is an open
mode flag. Probably those other compilers defined format flags and open mode
flags as both being type long, so they could not detect this error. gcc is
superior (in this respect at least).

john
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Slavik | last post by:
All libraries were installed (precompiled) This is FreeBSD 5.1 installed zlib, installed jpeg and png libraries (in default directories) GD 2.0.11 source is in /usr/gd-2.0.11 (compiled and...
0
by: Erik | last post by:
I try to participate in the translation of the PHP manual and want to install Jade. That one goes wrong: The configure of jade goes wrong. here is the tail of config.log and the tail of the...
0
by: Aliencat | last post by:
I'm having issues compiling php v4.2.2 on Redhat 9.0. The goal ultimately is to compile in mcrypt support, but that's a bit down the road from here. I've chased down the dependencies for the...
0
by: Ville Mattila | last post by:
Hello readers, I'm trying to install the latest PHP4 version from the scratch. The configure string is following: ../configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-curl...
5
by: Philip Goisman | last post by:
Hi, Hope someone can help. I have the following c++ program which compiles fine in gcc2.96, but won't compile in gcc3.2.2: //FMain.cpp #include <stdlib.h> #include <stdio.h> #include...
3
by: Georg | last post by:
Hello, I must be doing something wrong, but I don't get it: - compile gcc -c -O -Iinc src/hello.c -o obj/hello.o gcc -c -O -Iinc src/msg_1.c -o obj/msg_1.o gcc -c -O -Iinc src/msg_2.c -o...
5
by: Jagadish Kumar, Maripi | last post by:
Hi, I got the following error while trying to compile php with mysql. I would be glad if anyone can help me on this. Here is the error that i've got in config.log The command i used is:...
0
by: Jloyd | last post by:
Hi all, I wanted to install the cross compiler for m68k (motorola) GCC2.96+ or GCC 4.2 Beta version in cygwin. This compiler is used to compile the C source code. I got to know that the GCC...
0
by: nano2 | last post by:
Hi all, I am trying to link in shared objects but when i do I get undefined symbols with my LDFLAGS += -L $(PLATFORM_LIBS) I am can overcome this by using -shared however I don't want a shared...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.