LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-12-2007, 04:11 PM   #1
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 252

Rep: Reputation: 30
(SOLVED) g++ compiler error on iostream method .flags()


Hello, I'm trying to compile some code that uses a C++ ostream method called .flags().

This is a simple version of what the code is doing, and where the problem occurs.

Code:
#include <iostream>
#include <iomanip>
long originalformat = output_stream.flags(); // saves original format
// ...various other code
output_stream.flags(originalformat); // reset flags
The error happens on the last line where I try to set the output_stream's flags to the original value. I am using G++ version 4.1.2. Here is the compiler output error:

error: invalid conversion from 'long int' to 'std::_Ios_Fmtflags'
error: initializing argument 1 of 'std::_Ios_Fmtflags std::ios_base::flags(std::_Ios
_Fmtflags)'

Last edited by sadarax; 04-12-2007 at 05:22 PM.
 
Old 04-12-2007, 04:36 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
The type you should use in not long, but ios_base::fmtflags.

See:
http://www.cplusplus.com/reference/i.../fmtflags.html
 
Old 04-12-2007, 05:20 PM   #3
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 252

Original Poster
Rep: Reputation: 30
Thank you very much. That solved the problem.
 
  


Reply

Tags
c++, flags, g++



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for C compiler default output... configure: error: C compiler cannot create fiorejm Linux - Software 6 11-12-2009 12:35 PM
How do you set compiler flags in SuSE? Thaidog SUSE / openSUSE 0 12-26-2006 10:04 PM
eth0: ERROR while getting interface flags: No such device - using Kanotix adodo Linux - Networking 4 04-11-2006 04:04 AM
How to rebuild glibc with compiler flags designed for my system davidas Debian 1 04-19-2004 11:12 PM
cfgmgr errors out method error trew AIX 1 01-29-2004 12:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration