LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 05:11 PM   #1
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 249

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 06:22 PM.
 
Old 04-12-2007, 05:36 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

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, 06:20 PM   #3
sadarax
Member
 
Registered: Sep 2005
Distribution: Ubuntu
Posts: 249

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


Reply

Tags
c++, flags, g++


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:35 PM
How do you set compiler flags in SuSE? Thaidog SUSE / openSUSE 0 12-26-2006 11:04 PM
eth0: ERROR while getting interface flags: No such device - using Kanotix adodo Linux - Networking 4 04-11-2006 05:04 AM
How to rebuild glibc with compiler flags designed for my system davidas Debian 1 04-20-2004 12:12 AM
cfgmgr errors out method error trew AIX 1 01-29-2004 01:22 PM

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

All times are GMT -5. The time now is 12:52 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration