Welcome, Guest. Please login or register.

Author Topic: Unterminated Macro Call  (Read 4922 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Unterminated Macro Call
« 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:
Code: [Select]
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:
Quote
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.
Ed.
 

Offline Thomas

Re: Unterminated Macro Call
« Reply #1 on: April 21, 2009, 02:05:14 PM »

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

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: Unterminated Macro Call
« Reply #2 on: April 21, 2009, 02:32:25 PM »
After quick counting it seems you create 2 groups (Window_parentgroup and later a VGroup), but there is only one endgroup.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: Unterminated Macro Call
« Reply #3 on: April 22, 2009, 01:39:41 AM »
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:
Code: [Select]

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.
Ed.
 

Offline Thomas

Re: Unterminated Macro Call
« Reply #4 on: April 22, 2009, 11:38:05 AM »

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

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: Unterminated Macro Call
« Reply #5 on: April 23, 2009, 04:30:59 AM »
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.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: Unterminated Macro Call
« Reply #6 on: April 23, 2009, 04:31:49 AM »
Oh, and does anyone have any examples that they know works? I'm willing to try anything here.
Ed.
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: Unterminated Macro Call
« Reply #7 on: April 23, 2009, 04:47:03 AM »
Playing a hunch based on Thomas' comments, I changed the simplified code to look like this:
Code: [Select]

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:
Quote
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.
Ed.
 

Offline Heinz

  • Full Member
  • ***
  • Join Date: Nov 2005
  • Posts: 154
    • Show only replies by Heinz
    • http://amidevcpp.amiga-world.de
Re: Unterminated Macro Call
« Reply #8 on: April 23, 2009, 10:50:12 AM »
Quote

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.

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).
 

Offline EDanaIITopic starter

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 579
    • Show only replies by EDanaII
    • http://www.EdwardGDanaII.info
Re: Unterminated Macro Call
« Reply #9 on: April 24, 2009, 05:04:31 AM »
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.
Ed.
 

Offline unusedunused

  • Sr. Member
  • ****
  • Join Date: Nov 2005
  • Posts: 479
    • Show only replies by unusedunused
Re: Unterminated Macro Call
« Reply #10 on: May 30, 2009, 12:47:35 PM »
Quote from: EDanaII;451037

 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
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: Unterminated Macro Call
« Reply #11 on: May 30, 2009, 04:33:24 PM »
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.
My Amigas: A500, Mac Mini and PowerBook
 

Offline Georg

  • Jr. Member
  • **
  • Join Date: Feb 2002
  • Posts: 90
    • Show only replies by Georg
Re: Unterminated Macro Call
« Reply #12 on: May 30, 2009, 06:22:02 PM »
Yes. Unterminated Macro Call errors usually happen because of MUI/Reaction macros being defined like this:

Code: [Select]

#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.

Code: [Select]

#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)