Hi,
Now, right after resurrecting my X5000, I run into a problem. A real problem for which I hope you can point me in the right direction.
Please bear in mind that it USED to work! Virtually all of my released titles that make use of Reaction on OS4Depot use it. Right before I folded up some 5 years ago and put my X5000 in storage, I changed something and I don't know why, how and what.
An introduction might be in place here for you to grasp the underlying complexity of the problem, as I make use of what I think is a rather sophisticated way of ensuring the necessary classes for a project are opened, by including a '#include'-line for those classes.
#ifndef MAIN_H # define MAIN_H # include <interfaces/button.h> //# include <interfaces/checkbox.h> //# include <interfaces/chooser.h> //# include <interfaces/clicktab.h> //# include <interfaces/colorwheel.h> //# include <interfaces/datebrowser.h> //# include <interfaces/fuelgauge.h> //# include <interfaces/getcolor.h> # include <interfaces/getfile.h> //# include <interfaces/getfont.h> //# include <interfaces/getscreenmode.h> //# include <interfaces/integer.h> //# include <interfaces/listbrowser.h> //# include <interfaces/palette.h> //# include <interfaces/partition.h> //# include <interfaces/radiobutton.h> //# include <interfaces/scroller.h> //# include <interfaces/sketchboard.h> //# include <interfaces/slider.h> //# include <interfaces/space.h> //# include <interfaces/speedbar.h> //# include <interfaces/string.h> //# include <interfaces/texteditor.h> //# include <interfaces/virtual.h>
File 'main.h' is a physical component of any project and contains project-specific data.
Next is a file called 'Gadgets.h' and here a structure is defined (an array of, actually) and initialised.
struct GadDesc {CONST_STRPTR gd_Name; UWORD gd_Version; UWORD gd_Revision; struct ClassLibrary **gd_GadBase; Class **gd_Class; struct Interface **gd_IFace; uint32 gd_Failure; } GD[] = { /* ** --- classes -------------------------------------------------------------------------------------------------------------------------------------- */ # ifdef INTERFACES_AREXX_H { "arexx.class", ARexxLV, ARexxLR, (struct ClassLibrary **)&ARexxBase, (Class **)&ARexxClass, (struct Interface **)&IARexx, (uint32)0}, # endif # ifdef INTERFACES_POPUPMENU_H { "popupmenu.class", PopupLV, PopupLR, (struct ClassLibrary **)&PopupMenuBase, (Class **)&PopupMenuClass, (struct Interface **)&IPopupMenu, (uint32)0}, # endif
'Gadgets.h' is NOT physically present in a project, but by means of a link it is virtually present. All of these virtual files reside in 'BlackBox'.
The array of gadget descriptions is fed to a function called 'Open_Gadgets'.
Prototype for that function and it companions:
BOOL Open_Gadgets(struct GadDesc *); void Close_Gadgets(struct GadDesc *); void Report_FailedClasses(struct ExecParam *, struct GadDesc *);
The relation between these 3 is actually quite straightforward:
if (Open_Gadgets(GD)) { . . . } else { ERROR("Open one or more GadgetClasses"); Report_FailedClasses(xn, GD); } Close_Gadgets(GD);
where the argument 'GD' stands for a pointer to the array mentioned above.
The code for 'Open_Gadgets' is:
BOOL Open_Gadgets(struct GadDesc *GaDe) { INFO_ENTER BOOL Success = TRUE; struct GadDesc *gd = GaDe; while (gd->gd_Name != NULL) { if ((*gd->gd_GadBase = IIntuition->OpenClass(gd->gd_Name, 0, gd->gd_Class)) != NULL) { if ((*(uint32 *)&((struct ClassLibrary *)*gd->gd_GadBase)->cl_Lib.lib_Version) >= (*(uint32 *)&gd->gd_Version)) { if ((*gd->gd_IFace = IExec->GetInterface((struct Library *)*gd->gd_GadBase, "main", 1, NULL)) == NULL) { Success = FALSE; gd->gd_Failure = ERR_NO_INTERFACE; } } else { Success = FALSE; gd->gd_Failure = ERR_LIBVERSION; } } else { Success = FALSE; gd->gd_Failure = ERR_NO_LIB_FOUND; } gd++; } INFO_VACATE return Success; }
This function is, a.o., part of a file which is also virtually present in a project. In ANY of my projects, which use Reaction, a total of 8 files are virtually present. They contain macro's and functions alike that are proven to work properly. Until now, that is.
And now the offending line is the following one, which either gives a compiler warning or error, or a GR at runtime, depending on my efforts to remedy the problem:
if ((*gd->gd_GadBase = IIntuition->OpenClass(gd->gd_Name, 0, gd->gd_Class)) != NULL)
I know that it is a pointer-issue, but I'm at a loss.
The -> operator is stronger than the * operator. So *gd->gd_GadBase is equal to *(gd->gd_GadBase). This is not what you want. You want (*gd)->gd_GadBase and this is what you need to code. The brackets around *gd are missing.Edit: no, ignrore that. I didn't look carefully enough to your struct GadDesc. It's a really complicated thing you are building there.
After a lot of retyping code and applying all possible combinations of '*' and '&' alike without much success, I finally found the culprit. In the whole of the conversionprocess, many, many moons ago, I thought it a wise decision to eliminate the proto/.... files from the compilation sequence and go directly for the interfaces/.... files instead.
This has consequences for building up and initiating an array of struct LibDesc, quit simmilar to GadDesc, In stead of using
#ifdef INTERFACES_xxx_H
I had to ressort to
#ifdef xxx_INTERFACE_DEF_H
which I *forgot* for the most part. Especially for the intuition library.
Long story short: I can say that it works gain.
Thanks,
OldFart