Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » allegro and fstream errors

This thread is locked; no one can reply to it. rss feed Print
allegro and fstream errors
Frank Drebin
Member #2,987
December 2002
avatar

as the topic says if i include <fstream> and <allegro.h> i get a lot of errors.
so i searched the forums for a solution but even with the -D__GTHREAD_HIDE_WIN32API -flag i get errors like these:

cbot.cpp:26: error: use of 'fixed' is ambiguous
/usr/include/allegro/fixed.h:28: error:   first declared as 'typedef int32_t fixed' here
/usr/lib/gcc/i686-pc-linux-gnu/4.0.3/../../../../include/c++/4.0.3/bits/ios_base.h:951: error:   also declared as 'std::ios_base& std::fixed(std::ios_base&)' here
...

what to do now?

CGamesPlay
Member #2,559
July 2002
avatar

Show us the line with the error.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Frank Drebin
Member #2,987
December 2002
avatar

cbot.cpp:26

fixed distance=itofix(1000);

seems to be some conflict with the fixed format.

Matthew Leverton
Supreme Loser
January 1999
avatar

Do you happen to have a using namespace in your headers?

Carrus85
Member #2,633
August 2002
avatar

Yes, do NOT do using namespace std if you are going to be using fixed. (Since std::fixed is a stream manipulator, you will end up with (std::)fixed and fixed in your namespace).

Indeterminatus
Member #737
November 2000
avatar

::fixed distance=itofix(1000);

_______________________________
Indeterminatus. [Atomic Butcher]
si tacuisses, philosophus mansisses

Frank Drebin
Member #2,987
December 2002
avatar

Quote:

Do you happen to have a using namespace in your headers?

No!

Quote:

::fixed distance=itofix(1000);

this works but is this really the only way?
and what does this exactly - in all my source files where i use the std-code there is a "using namespace std" ?

CGamesPlay
Member #2,559
July 2002
avatar

It tells the compiler to use the version of fixed not in any namespace--the one on the global scope.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Frank Drebin
Member #2,987
December 2002
avatar

so there isn't an workaround for this?
i can't imagine that i'm the only one who got this problem...

CGamesPlay
Member #2,559
July 2002
avatar

Nobody uses fixeds :P

And the workaround is not to use using namespace std;. This is the reason namespaces exist.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Frank Drebin
Member #2,987
December 2002
avatar

you mean to use the :: (scope-operator), heh?
there is no such thing like a namespace allegro, right?

Indeterminatus
Member #737
November 2000
avatar

Quote:

there is no such thing like a namespace allegro, right?

Right.

And as for the workaround: If you don't want to use ::, and you also don't want to write std:: everywhere, instead of using namespace std; you can put using std::vector; for example (of course, you'd have to do that for everything you're using from the std namespace).

As long as you don't write using std::fixed; then, fixed isn't ambiguous, hence you won't need to explicitly identify which one you want.

_______________________________
Indeterminatus. [Atomic Butcher]
si tacuisses, philosophus mansisses

Frank Drebin
Member #2,987
December 2002
avatar

ok thanks
or i'll change my fixed to float...

Go to: