Mail Archives: djgpp/1999/10/31/01:59:49
On 30 Oct 99, at 20:46, Andrew R. Gillett
<arg AT whangomatic DOT freeserve DOT co DOT uk> wrote:
> I am pretty sure the test program below would work on
> 2.8.1, but on 2.9.5 it doesn't compile:
>
>
> #include <allegro.h>
>
> #include <string>
>
> int main (void)
> {
> string my_string = "Hello";
>
> allegro_init();
>
> set_gfx_mode (GFX_AUTODETECT, 320, 200, 0, 0);
>
> textout (screen, font, my_string.c_str(), 0, 0,
> makecol(255,255,255));
>
> exit (0);
> }
Hello Andrew!
I am not a C++ programmer but I think the problem is that the
textout function needs a char * as it's third argument while
my_string.c_str() returns const char * .
So the easiest thing would be to cast the value to char * as follows.
textout (screen, font, (char *)my_string.c_str(), 0, 0,
makecol(255,255,255));
Because after making this change I compiled your program using
gcc 2.95.1 using 'gcc test.cpp -o test.exe -Wall -lalleg -lstdcx'
and it compiled OK.
Maybe it would work on 2.81 because 2.81 is less strict in certain
area's of C++.
BTW you might need a getch() to wait for a keypress after textout
because otherwise the program will exit to dos (and textmode) and
you won't see it's output.
Also you might try searching the mail archives at DJ's site
<www.delorie.com> because there was a discussion on this list
about const char * and Allegro about a month ago(if I remember
correctly).
Bye!
Kalum
- Raw text -