![]() |
|
learning allegro using a book, is this code flawed in the book or is it my comp |
ansimega
Member #7,984
November 2006
|
Hi, i am learning to code with c& allegro, here is a script in the book it ask me to compile. I have already set the linker commands in my compiler "using dev c++" #include <stdlib.h> int main(){ errors make.exe -f "C:\Documents and Settings\computer\Desktop\gameprogramming\ch2\Makefile.win" all GetInfo/getinfo.cpp: In function `int _mangled_main()': make.exe: *** [GetInfo/getinfo.o] Error 1 Execution terminated |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Add: #include <stdio.h> to the top of your file. -- |
Richard Phipps
Member #1,632
November 2001
![]() |
add: EDIT: MOOOOOOSSSSEEEE!!!! |
LennyLen
Member #5,313
December 2004
![]() |
You need to add the following line at the start: #include <stdio.h> Edit: Darn, beaten by a blue friendly monster! Edit2: And a moose!
|
Johan Peitz
Member #9
April 2000
![]() |
I'm pretty sure you need to include stdio.h to get printf... Also, system("pause") isn't very nice... EDIT: Wow, for responses on the same minute. -- |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Ok, Wow. 4 messages at the same time. -- |
LennyLen
Member #5,313
December 2004
![]() |
Who wants to play "Guess the book title?"
|
Richard Phipps
Member #1,632
November 2001
![]() |
If the book example is going to use Allegro why not use rest() or readkey()? |
LennyLen
Member #5,313
December 2004
![]() |
Quote: If the book example is going to use Allegro why not use rest() or readkey()? Well, if the author is silly enough to forget to include stdio.h...
|
ansimega
Member #7,984
November 2006
|
Thanks guys, the book is called Game Programming All In One by Jonathan S. Harbour, he claimed he tested the code on every type of operating system. |
Richard Phipps
Member #1,632
November 2001
![]() |
Thomas Fjellstrom
Member #476
June 2000
![]() |
He also claims to be a writer and a programmer. -- |
CGamesPlay
Member #2,559
July 2002
![]() |
By the way... I don't know if the book tells you to use C or C++, but that code will compile fine if you made it a "C" file instead of a "C++" file. The "++" is for extra errors! -- Ryan Patterson - <http://cgamesplay.com/> |
Evert
Member #794
November 2000
![]() |
Quote: is this code flawed in the book If it's the book I think it is, then yes, it is. EDIT Quote: the book is called Game Programming All In One That's the one! Quote: he claimed he tested the code on every type of operating system. He blatently didn't. He also claimed "Allegro 4.2 is not backward compatible", which is false. |
LennyLen
Member #5,313
December 2004
![]() |
Evert said: If it's the book I think it is
ansimega said: the book is called Game Programming All In One by Jonathan S. Harbour
Edit: aha, I see you read back through the thread.
|
Onewing
Member #6,152
August 2005
![]() |
In GPAIO edition 2, here's that same bit of code: #include <conio.h> #include <stdlib.h> #include "allegro.h" int main() { allegro_init(); printf("Allegro version = %s\n", allegro_id); printf("\nPress any key...\n"); getch(); return 0; } END_OF_MAIN(); Just for reference... ------------ |
LennyLen
Member #5,313
December 2004
![]() |
Quote: In GPAIO edition 2, here's that same bit of code: Which still won't compile since stio.h is again not included. Even if it were, conio.h functions are not part of the C standard.
|
Onewing
Member #6,152
August 2005
![]() |
Apparently, he wrote this code first:
And the next bit he adds the allegro stuff to that code. Somehow, stdio.h turned into stdlib.h for some reason. Also note in the first bit (the code I just posted), there's no return value at the end of main. Given, he didn't say this book was meant to be used for learning C nor did he mention it uses standard C. ------------ |
LennyLen
Member #5,313
December 2004
![]() |
Quote: Somehow, stdio.h turned into stdlib.h for some reason. In the post by the OP, the book uses system(). This function resides in stdlib.h. Quote: Given, he didn't say this book was meant to be used for learning C nor did he mention it uses standard C.
I guess he assumed all readers would be using DOS or Windows.
|
Thomas Fjellstrom
Member #476
June 2000
![]() |
I think he assumed it was all money in his pocket, no matter what OS they used. -- |
Matthew Dalrymple
Member #7,922
October 2006
![]() |
Thomas Fjellstrom said: He also claims to be a writer and a programmer. That made me laugh, big time :-D =-----===-----===-----= |
|