Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: EDanaII on April 21, 2009, 02:14:55 AM
-
I'm attempting to learn Reaction for AmigaOS 3.9. Unfortunately, I'm encountering a problem for which I have no clue. I'd post this on UtilityBase, but it's still under the Google's "Attack Site" thumb, making navigation a pain in the S over there.
Whenever I try to compile this Reaction example:
objects[OID_MAIN] = WindowObject,
WA_ScreenTitle, "Reaction",
WA_Title, "Reaction CheckBox Example",
WA_Activate, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
WINDOW_IconifyGadget, TRUE,
WINDOW_IconTitle, "CheckBox",
WINDOW_AppPort, AppPort,
WINDOW_Position, WPOS_CENTERMOUSE,
WINDOW_ParentGroup, gadgets[GID_MAIN] = VGroupObject,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_DeferLayout, TRUE,
LAYOUT_AddChild, gadgets[GID_CHECKBOX1] = CheckBoxObject,
GA_ID, GID_CHECKBOX1,
GA_RelVerify, TRUE,
GA_Text, "CheckBox _1",
CHECKBOX_TextPlace, PLACETEXT_RIGHT,
CheckBoxEnd,
CHILD_NominalSize, TRUE,
LAYOUT_AddChild, gadgets[GID_CHECKBOX2] = CheckBoxObject,
GA_ID, GID_CHECKBOX2,
GA_RelVerify, TRUE,
GA_Text, "CheckBox _2",
CHECKBOX_TextPlace, PLACETEXT_LEFT,
CheckBoxEnd,
LAYOUT_AddChild, VGroupObject,
GA_BackFill, NULL,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_VertAlignment, LALIGN_CENTER,
LAYOUT_HorizAlignment, LALIGN_CENTER,
LAYOUT_BevelStyle, BVS_FIELD,
LAYOUT_AddImage, LabelObject,
LABEL_Text, "The checkbox may have its label placed\n",
LABEL_Text, "either on the left or right side.\n",
LABEL_Text, " \n",
LABEL_Text, "You may click the label text as well\n",
LABEL_Text, "as the check box itself.\n",
LabelEnd,
LayoutEnd,
LAYOUT_AddChild, ButtonObject,
GA_ID, GID_QUIT,
GA_RelVerify, TRUE,
GA_Text,"_Quit",
ButtonEnd,
CHILD_WeightedHeight, 0,
EndGroup,
EndWindow;
I get the following error:
134 W:\Projects\Amiga\Reaction\CheckBox\checkboxexample.c unterminated macro call
I know what a macro is, but I have no idea how to "terminate it." (Short of calling for Arnie's help, that is).
I'm using AmiDevCpp and compiling to a standard Amiga C++ program. I tried downloading their Reaction.DevPak but I end up with the MUI.DevPak instead. (Which has it's own problems too, I'll post on that later).
Any and all clues appreciated.
Ed.
-
A macro call usually looks like macroname(arg1,arg2). An unterminated macro call just means that the right parenthesis is missing.
In your example it's probably a missing comma or a misplaced EndObject or something like that.
Bye,
Thomas
-
After quick counting it seems you create 2 groups (Window_parentgroup and later a VGroup), but there is only one endgroup.
-
I noticed that too, Kronos, but not knowing enough about what's going on here I wasn't sure.
@ Thomas
Yea, I thought that might be the case, but the fact that I've used macros so little combined with the non-standard (for me) creation of the window, makes me unsure of just what's going on here.
@ Both
The problem is, even when I simplify the structure to just this:
objects[OID_MAIN]
= WindowObject,
WA_ScreenTitle, "Reaction",
WA_Title, "Reaction CheckBox Example",
WA_Activate, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
End;
I still get the unterminated macro error. Once again, I don't have enough understanding to diagnose what the real problem is, and for all I know, I didn't simplify it correctly or terminated it properly, yada, yada, yada...
Once again, if anyone has any ideas, I'd love to hear them.
Thanks,
Ed.
-
Make sure you #include and as well as . Also make sure that you use a consistent set of include files. Don't mix OS 4 includes with OS 3 includes.
Bye,
Thomas
-
Well, I doubt that I'll ever mix OS 3.9 with OS 4.0 since I don't have much use for a PPC machine. (Yep, I'm in the x86 camp). :)
I should probably be doing this in MUI, since Zune is its "clone" from AROS, but as I'm doing this more for fun than seriously, I want to try Reaction just for giggles.
I was missing "proto/window.h", but putting it in the source file doesn't cure the problem. I'm still getting the Macro error.
Any other ideas?
Ed.
-
Oh, and does anyone have any examples that they know works? I'm willing to try anything here.
-
Playing a hunch based on Thomas' comments, I changed the simplified code to look like this:
objects[OID_MAIN]
= WindowObject,
WA_ScreenTitle, "Reaction",
WA_Title, "Reaction CheckBox Example",
WA_Activate, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE
);
Notice that the macro "End" has been changed to a ");".
This gets rid of the unterminated macro error and instead gives me new and more puzzling errors:
W:\Projects\Amiga\Reaction\CheckBox\checkboxexample.c In function `int main()':
138 W:\Projects\Amiga\Reaction\CheckBox\checkboxexample.c initialization to `long unsigned int' from `const char *' lacks a cast
138 W:\Projects\Amiga\Reaction\CheckBox\checkboxexample.c initialization to `long unsigned int' from `const char *' lacks a cast
138 W:\Projects\Amiga\Reaction\CheckBox\checkboxexample.c ANSI C++ forbids implicit conversion from `void *' in assignment
W:\Projects\Amiga\Reaction\CheckBox\Makefile.win [Build Error] exe: *** [checkboxexample.o] Error 1
That the two strings are being miscast to longs makes no sense whatsoever, since those positions are clearly string constants.
(I'm ready shave my head, become a monk and give up programming forever... somebody stop me before it's to late.) ;-)
Ed.
-
EDanaII wrote:
Oh, and does anyone have any examples that they know works? I'm willing to try anything here.
This is a simple Reaction Program I did several years ago. (http://amidevcpp.amiga-world.de/Examples/info/Bitoperation.zip.php)
Even If a lot of people will not like it, I have to say that I wouldnt recommend Reaction for new Projects. I dont say that it is bad, but it is OS3.9/4.x only so your Projects wont be portable. And it is closed source, so if AmigaOS4 "dies" Reactions dies to. Better use MUI. It is well documented, it is available on all Amiga like OS`s and there is an open source clone available (ZUNE).
-
Thanks, Heinz. Your example actually compiles. I'll play with it more a little later. Unfortunately, my priorities have shifted now that my father is in the hospital. :(
Your point about OS3.9/4.0 is well taken, but I'm only doing this to sharpen my C/C++ skills. As to MUI, I've been trying it too, but it doesn't compile either. When I'm ready, I'll post my difficulties with it here later, but later, when things settle down.
Ed.
-
was missing "proto/window.h", but putting it in the source file doesn't cure the problem. I'm still getting the Macro error.
Any other ideas?
you should post the source and what the preprocessor generate from the macros, then can say more.
compiler Option -E output of preprocessor in ascii (expandet macros) in current .o dest file
-
It seems this is the usual "macro in macro" problem. Either replace macro "End" to "TAG_DONE)" or switch from inline vararg calls to stub calls.
-
Yes. Unterminated Macro Call errors usually happen because of MUI/Reaction macros being defined like this:
#define WindowObject NewObject( WINDOW_GetClass(), NULL
As can be seen the closing bracket for NewObject is missing. This will be added when taglist is closed with End or TAG_DONE). When the vararg function NewObject itself is defined as macro (inline stdarg) it causes the error because of the way and order macro expansion is done, obviously.
So this macros only work if NewObject itself is not a macro == when not using inline stdarg.
AROS defines macros like WindowObject in a different way - with no missing close bracket - and to be able to do that it requires some more magic for the "End" macro. This way it works even if the vararg function NewObject is a macro, too. A disadvantage would be that it can clash if two libs' includes are used which both use the "End" macro. Like popupmenu + MUI. Then even more magic would be needed for the "End" macro to figure out if it is a MUI call, or a popupmenucall.
#define MUIOBJMACRO_START(class) (IPTR) \
({ \
ClassID __class = (ClassID) class; \
enum { __ismuiobjmacro = 1 }; \
IPTR __tags[] = {0
#define BOOPSIOBJMACRO_START(class) (IPTR) \
({ \
Class *__class = (Class *) class; \
enum { __ismuiobjmacro = 0 }; \
IPTR __tags[] = {0
#define OBJMACRO_END \
TAG_DONE}; \
( \
__ismuiobjmacro \
? MUI_NewObjectA((ClassID)__class, (struct TagItem *)(__tags + 1)) \
: NewObjectA((Class *)__class, NULL, (struct TagItem *)(__tags + 1)) \
); \
})
#define End OBJMACRO_END
#define WindowObject MUIOBJMACRO_START(MUIC_Window)