Welcome, Guest. Please login or register.

Author Topic: Why doesn't this code starts automatically (full example with ports and message)...Also SAS linking  (Read 3941 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show only replies by Jose
Re: Why doesn't this code starts automatically (full example with ports and message)...Also SAS link
« Reply #14 from previous page: September 27, 2004, 12:15:54 PM »
Bump...
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show only replies by Jose
By the way, it's not the NP_Cli tag either. I though that could be causig the NewProcess startup to treat it like a Cli process and not remove the WBStartup message before using the DOS library functions. But it still crashes when launched from WB :pissed:
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show only replies by Jose
Found the {bleep}!! :-x

It's in this line:

Code: [Select]
if (!(Message_to_OtherProcess  = (struct Message_to_OtherProcess *)AllocMem (sizeof(Message_to_OtherProcess),MEMF_PUBLIC|MEMF_CLEAR)))
 
I guess it should be obvious. Do I look stupid now? 8-)
But I guess it's with errors like these that one learns.

I can now go on with the other stuff  :-D
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Quote
Jose wrote:
I guess it should be obvious. Do I look stupid now? 8-)

Ah, bloody hell. Jeez. Well, yeah. After staring at it for five minutes, it struck me: you forgot a struct in the sizeof-operator. I've been in the habit of typedef'ing my structures so I don't have to write down the keyword all the time, and as an added bonus can use a simple type to indicate a pointer to the structure. So the missing keyword never bothered me, as I have not written one myself in such a situation since 1998 :-D. (C++ does this automatically for you, by the way, and I think this is a Good Thing.)

In your case it would mean that you write:

typedef struct Message_to_OtherProcess  MtoOP;
typedef struct Message_to_OtherProcess *MtoOPptr;


and then use program lines like

if (!(Message_to_OtherProcess = (MtoOPptr)AllocMem(sizeof(MtoOP), MEMF_CLEAR|MEMF_PUBLIC)))

I can recommend such abbreviations, they help you guard against mistakes like this, plus it makes programs easier to read: there is never any confusion about whether something is a true variable, or a meta-variable.
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.