|
This thread is locked; no one can reply to it. |
1
2
|
Problems compiling excustom.c |
inspiredevistate
Member #7,980
November 2006
|
DIALOG the_dialog[] = { /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ { d_clear_proc, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, NULL, NULL, NULL }, { d_edit_proc, 32, 32, 256, 8, 255, 0, 0, 0, sizeof(the_string)-1, 0, the_string, NULL, NULL }, { d_check_proc, 32, 64, 89, 13, 255, 0, 't', 0, 0, 0, "&Toggle Me", NULL, NULL }, { clock_proc, 192, 64, 64, 64, 255, 0, 0, 0, 0, 0, NULL, NULL, NULL }, { d_button_proc, 120, 160, 81, 17, 255, 0, 0, D_EXIT, 0, 0, "Exit", NULL, NULL }, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; I am trying to compile the excustom.c file provided by Allegro. But when I try to compile I always get the error message initializer element is not a constant (near initialization for 'the_dialog[0].proc')
and so on down the list for each one of the proc's and the NULL |
LennyLen
Member #5,313
December 2004
|
what compiler are you using, and what parameters are you passing to it?
|
inspiredevistate
Member #7,980
November 2006
|
I am using Dev-C++ no params |
LennyLen
Member #5,313
December 2004
|
Start a command prompt and navigate to the examples directory, then enter the following: gcc excustom.c -o excustom.exe -lalleg
|
inspiredevistate
Member #7,980
November 2006
|
still says the same thing initializer element is not a constant all the way to the_dialog[5] |
Hrvoje Ban
Member #4,537
April 2004
|
How is the_string defined? |
inspiredevistate
Member #7,980
November 2006
|
char the_string[32] = "Change Me!"; is anyone else having problems compiling excustom.c? |
LennyLen
Member #5,313
December 2004
|
Quote: is anyone else having problems compiling excustom.c? It compiled perfectly from the command line for me, using the call to gcc that I gave in my previous post. If there's still a problem, then it's either your gcc or allegro installation causing it. Did you install gcc (MinGW) directly, or get Dev-C++ to do it for you? Likewise for Allegro.
|
DanielH
Member #934
January 2001
|
We've had this topic before. I did a search and voila. C++ requires casting in certain places that C does not. http://www.allegro.cc/forums/thread/176811 Put a '(void *)' in front of the strings. (void*)"&Toggle Me" Or tell DevC++ to compile it as a C file. |
LennyLen
Member #5,313
December 2004
|
I guess the following line (from the orignal post) wasn't true then: Quote: I am compiling the code as C code. Edit: I just read the thread you linked to. That's an entirely different error.
|
inspiredevistate
Member #7,980
November 2006
|
I am compiling the code in C. Everything works fine except for the proc's (d_clear_proc, etc.) Also, I guess Dev-C++ installed gcc for me. When I try to compile, i get errors from the d_xxxx_proc's When I take them out, I dont get the error, it just doesnt work |
LennyLen
Member #5,313
December 2004
|
Quote: I am compiling the code in C. The command line call I told you to try will compile as C as well, which I should have taken into consideration in my previous post, but didn't. The only other thing I can think of is manually installing MinGW and Allegro yourself instead of letting Dev-C++ do it, since that's the only difference between your setup and mine, and it works flawlessly for me. However, I'm sure that with the number of people that use Dev-C++, someone else would have come across this problem before if it's the cause.
|
inspiredevistate
Member #7,980
November 2006
|
well i have narrowed it down to the d_xxxx_proc calls |
LennyLen
Member #5,313
December 2004
|
Quote: well i have narrowed it down to the d_xxxx_proc calls Yes, but the same calls compile fine for me, so they're not the problem per se.
|
kazzmir
Member #1,786
December 2001
|
Just a check, what does 'gcc -v' say? |
inspiredevistate
Member #7,980
November 2006
|
Quote: kazzmir: Just a check, what does 'gcc -v' say? gcc version 3.2 (mingw special 20020817-1) |
LennyLen
Member #5,313
December 2004
|
Quote: gcc version 3.2 (mingw special 20020817-1) Yep, that's the version that gets installed by Dev-C++. The latest MinGW is gcc 3.4.2.
|
inspiredevistate
Member #7,980
November 2006
|
so i need gcc 3.4.2? |
LennyLen
Member #5,313
December 2004
|
Quote: so i need gcc 3.4.2? I don't know if that's the problem or not, but it certainly wouldn't hurt to update to a later version.
|
inspiredevistate
Member #7,980
November 2006
|
do you have the link by any chance? |
LennyLen
Member #5,313
December 2004
|
The easiest way to get MinGW is to use the automated installer.
|
inspiredevistate
Member #7,980
November 2006
|
okay i now have gcc 3.4.2, maybe it is allegro. maybe i need to update What version are you using to compile.. i have 4.0.0 I have downloaded 4.2.0, how do I set the MINGDIR environment variable under Windows XP? I'm looking at the documentation, but i can't seem to figure it out |
kazzmir
Member #1,786
December 2001
|
From memory but.. Right click on "my computer" -> properties -> user profile or environment -> edit the PATH in the top box or add MINGDIR |
LennyLen
Member #5,313
December 2004
|
Kazzmir was pretty close. After right clicking and selecting "properties" on My Computer (or selecting "System" from the Control Panel), it goes: Advanced -> Environment Variables. I always just add the "d:\mingw\bin" (your location may vary) directory to the path myself and don't bother with setting a MINGDIR variable.
|
inspiredevistate
Member #7,980
November 2006
|
Thanks for all of your help! I think I have figured this buggy question out!! I don't think the version of my gcc was the problem (although i did upgrade).. I was running alleg40.dll and changed to alleg42.dll, and now the dialog programs compile no problem!! Thanks again! |
|
1
2
|