allegro and fstream errors
Frank Drebin

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

Show us the line with the error.

Frank Drebin

cbot.cpp:26

fixed distance=itofix(1000);

seems to be some conflict with the fixed format.

Matthew Leverton

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

Carrus85

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
::fixed distance=itofix(1000);

Frank Drebin
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

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

Frank Drebin

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

CGamesPlay

Nobody uses fixeds :P

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

Frank Drebin

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

Indeterminatus
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.

Frank Drebin

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

Thread #586045. Printed from Allegro.cc