discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird warning


From: Chris B. Vetter
Subject: Re: Weird warning
Date: Tue, 18 Mar 2003 15:07:43 -0800

On Tue, 18 Mar 2003 21:56:52 +0100
Pascal Bourguignon <pjb@informatimago.com> wrote:
> If  it  is  a static  function  in  Foobar.m,  it  should not  have  a
> declaration  in Foobar.h.   In interface  files, you  should  put only
> external declarations.

That's obvious ;-)

No, I had a

  static BOOL initPattern(char **pattern, BOOL flag);

in Foobar.m which I cut&paste'd to foobar.h (the header file for
foobar.c) not Foobar.h (the header for Foobar.m), changing the 'static'
to 'extern' of course.

> Check the  definitions of the function  in Foobar.m, perhaps  it has a
> different signature.

Nope, absolutely identical, as I said, cut&paste.

> Now, look at the signature of the cString method in NSString.h:
>           - (const char*) cString;
> the 'const' here means that the returned string MUST NOT be modified.

Exactly, therefor the (char *) cast... since I do modify it later on.

> Therefore, you should declare pat as:
>       const char* pat=[pattern cString];
> and you should declare: 
>       BOOL initPattern(const char** pattern,BOOL flag)
> In  initPattern, you  cannot modify  the content  of the  memory block
> pointed  by  (*pattern)  (that  is,  (*pattern)[i]).   You  can  still
> allocate a new memory block and return it thru (*pattern).

Unfortunately, that's not really an option, as pattern will be passed to
several other functions from initPattern, which all will modify it.

> If I understand  well what you want to do, you  should have four files

Correct, four files.
For the sake of shortness, I called them Foobar.[h,m] and foobar.[c,h]
in this mail. (Maybe I should have used Foo.* and bar.* ... sorry)

> Unfortunately, this  does not explain  the "strange" warning.  My best
> guess  is that  you have  the initPattern  signature different  in the
> interface than in the implementation files.

Nope. That was my first guess, too. *sigh* Anyway, thanks for the
suggestions...

-- 
Chris




reply via email to

[Prev in Thread] Current Thread [Next in Thread]