Message-Id: <199910311638.KAA12881@lakdiva.slt.lk> From: "Kalum Somaratna aka Grendel" To: djgpp AT delorie DOT com Date: Sun, 31 Oct 1999 10:37:29 +0600 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: How can I get this program to compile? CC: arg AT whangomatic DOT freeserve DOT co DOT uk In-reply-to: X-mailer: Pegasus Mail for Win32 (v3.12) Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 30 Oct 99, at 20:46, Andrew R. Gillett 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 > > #include > > 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 because there was a discussion on this list about const char * and Allegro about a month ago(if I remember correctly). Bye! Kalum