Welcome, Guest. Please login or register.

Author Topic: Error on DoMethod()  (Read 977 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JettahTopic starter

  • Full Member
  • ***
  • Join Date: Nov 2003
  • Posts: 115
    • Show only replies by Jettah
Error on DoMethod()
« on: December 08, 2004, 04:41:57 PM »
Hi,

While designing a simple program I encountered an error and a warning when using DoMethod().

Here is a part of the offending source:

struct Window *Win = NULL;
if (Win = (struct Window *)DoMethod(&WinObj, WM_OPEN, NULL))
{
//anything usefull here
}

The warning is: cast does not match function type
The error sounds: Win has an incomplete type

Can anyone shed some light on this matter?

Regards,

Jettah
Sometimes I wish I was Mt Vesuvius: laying on my back in the sun while smoking a bit and everybody seeing me would say: \\"Look! He\\\'s active!\\" (author unknown to me)
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Error on DoMethod()
« Reply #1 on: December 08, 2004, 04:55:41 PM »
Quote
if Win = (struct Window *)DoMethod(&WinObj, WM_OPEN, NULL))

Missing parenthesis.

if (moo)
not
if moo
 

Offline JettahTopic starter

  • Full Member
  • ***
  • Join Date: Nov 2003
  • Posts: 115
    • Show only replies by Jettah
Re: Error on DoMethod()
« Reply #2 on: December 08, 2004, 05:02:36 PM »
@Piru

Stands corrected. My keyboard is a bit sticky on that particular key.

The source code however does contain that parenthesis.

Thanks anyway

Jettah
Sometimes I wish I was Mt Vesuvius: laying on my back in the sun while smoking a bit and everybody seeing me would say: \\"Look! He\\\'s active!\\" (author unknown to me)
 

Offline DaveP

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2116
    • Show only replies by DaveP
Re: Error on DoMethod()
« Reply #3 on: December 08, 2004, 05:32:31 PM »
Sounds like an include problem. Gcc and similar compilers report "incomplete type" for structures that are used but not declared.

In this case win is not defined, because the "struct Window" structure has not been declared in entirity. Check you have all the intuition includes required in order to use it.

Hate figure. :lol:
 

Offline JettahTopic starter

  • Full Member
  • ***
  • Join Date: Nov 2003
  • Posts: 115
    • Show only replies by Jettah
Re: Error on DoMethod()
« Reply #4 on: December 08, 2004, 05:41:15 PM »
@DaveP

"Check you have all the intuition includes required in order to use it."

struct Window is defined in intuition/intuition.h, which is included.

Thanks

Jettah

Sometimes I wish I was Mt Vesuvius: laying on my back in the sun while smoking a bit and everybody seeing me would say: \\"Look! He\\\'s active!\\" (author unknown to me)
 

Offline Thomas

Re: Error on DoMethod()
« Reply #5 on: December 09, 2004, 07:00:11 AM »

What about DoMethod ? Did you include proto/intuition.h and are you compiling with -D__USE_INLINES ?

And what about WinObj ? Usually I'd declare it as Object *WinObj. As such it already is a pointer to an object and you give a pointer to the pointer to DoMethod. You should rather give the pointer itself.

Bye,
Thomas

Offline nicomen

  • Jr. Member
  • **
  • Join Date: Feb 2002
  • Posts: 57
    • Show only replies by nicomen
    • http://home.polarboing.com/nicomen
Re: Error on DoMethod()
« Reply #6 on: December 09, 2004, 07:07:30 AM »
Which Amiga platform and version are you using?

What does the same line look after compiling with -E, ie. just running the preprocessor over it. Does DoMethod get delcared somewhere?

If OS4 and using __USE_INLINE__ add -DDoMethod=IDoMethod to GCC. if not using __USE_INLINE__ try adding -DDoMethod="IIntuition->IDoMethod"

UtilityBase.com - Your Guide To Amiga Development
#amigadev @ irc.utilitybase.com
 

Offline JettahTopic starter

  • Full Member
  • ***
  • Join Date: Nov 2003
  • Posts: 115
    • Show only replies by Jettah
Re: Error on DoMethod()
« Reply #7 on: December 09, 2004, 08:31:19 AM »
@Thomas


Up to now I have this piece of source code (relevant part only):

{                                                 // level 0
Object *WinObj = NULL;
if (WinObj = )
{                                                 // level 1
struct Window *Win = NULL;
if (Win = struct Window *)DoMethod(WinObj, WM_OPEN, NULL))
{                                                 // level 2
// Try to do the usefull stuff here...

DoMethod(WInObj, WM_CLOSE, NULL);
Win    = NULL;
WinSig = 0L;
}                                                 // level 2
DisposeObject((Object *)WinObj);
WinObj = NULL;
}                                                 // level 1
}                                                 // level 0

I now get the WARNING: cast does not match funktion type
intuition protos are included explicitly:
#include

Sytem used: A1200 OS3.9 StormC4 Gcc

Why, oh why, do I get a warning about a cast? IMHO I'm doing it the correct way, but I can be wrong of course.

Thanks,

Jettah
Sometimes I wish I was Mt Vesuvius: laying on my back in the sun while smoking a bit and everybody seeing me would say: \\"Look! He\\\'s active!\\" (author unknown to me)
 

Offline Thomas

Re: Error on DoMethod()
« Reply #8 on: December 09, 2004, 09:33:36 AM »

nicomen is correct. I remembered that DoMethod has been moved from amiga.lib to intuition.library with OS4.0, but I missed that it was also renamed to IDoMethod.

On OS3.9 you have to include clib/alib_protos.h for the DoMethod prototype.

Sometimes you should look into the include files. If you don't find DoMethod in intuition_protos.h, you know that you missed another include file.

Bye,
Thomas

Offline JettahTopic starter

  • Full Member
  • ***
  • Join Date: Nov 2003
  • Posts: 115
    • Show only replies by Jettah
Re: Error on DoMethod()
« Reply #9 on: December 09, 2004, 09:54:47 AM »
@Thomas

Quote
On OS3.9 you have to include clib/alib_protos.h for the DoMethod prototype.


This file has been included (was included all the way).

Changed the offending line.
FROM:
if (Win = (struct Window *)DoMethod(WinObj, WM_OPEN, NULL))

TO:
if ((ULONG)Win = DoMethod(WinObj, WM_OPEN, NULL))

The WARNING has now gone, but I do have a feeling that it is not a correct way of doing things. Am I wrong in this respect?

EDIT:
The program compiles and links well. It executes fine, so I assume it is correct now!

Thanks, for all your remarks, wisdom and knowledge. I'm very satisfied.
To me, this topic is closed.

Jettah
Sometimes I wish I was Mt Vesuvius: laying on my back in the sun while smoking a bit and everybody seeing me would say: \\"Look! He\\\'s active!\\" (author unknown to me)