Re: regcmp warning: improper pointer/integer combination: op "="
Jens.Toerring_at_physik.fu-berlin.de
Date: 03/09/05
- Next message: bjrnove: "Re: string array"
- Previous message: Michael Mair: "Re: C FAQ 2.18"
- In reply to: DHOLLINGSWORTH2: "Re: regcmp warning: improper pointer/integer combination: op "=""
- Next in thread: DHOLLINGSWORTH2: "Re: regcmp warning: improper pointer/integer combination: op "=""
- Reply: DHOLLINGSWORTH2: "Re: regcmp warning: improper pointer/integer combination: op "=""
- Reply: Flash Gordon: "Re: regcmp warning: improper pointer/integer combination: op "=""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 9 Mar 2005 09:24:14 GMT
DHOLLINGSWORTH2 <DHOLLINGSWORTH2@cox.net> wrote:
> "Flash Gordon" <spam@flash-gordon.me.uk> wrote in message
> news:l8r0g2xgdc.ln2@brenda.flash-gordon.me.uk...
>> jose_luis_fdez_diaz_news@yahoo.es wrote:
>>> Hi,
>>>
>>> If I don't include <libgen.h> I get then warnig below in regcmp call:
>>>
>>> warning: improper pointer/integer combination: op "="
>>>
>>> but if I include it the warning is not shown, but them program compiles
>>> fine.
>>>
>>> What is the warning shown ?
>>
>> Well, without the source code one can only guess. However, I would assume
>> regcmp (which is not part of standard C) returns some kind of pointer, and
>> that you are assigning it to an appropriate pointer variable. I further
>> assume that the non-standard header libgen.h provides a prototype for the
>> non-standard regcmp function.
>>
>> In C, if there is no declaration of a function in scope when it is used it
>> is assumed to return an int. The compiler is required to issue a
>> diagnostic (a warning in this case) when you assign an int directly to a
>> pointer, which is what is occurring without the prototype that libgen.h
>> probably provides.
>>
>> So include the headers (I assume libgen.h) that the manuals (or man pages)
>> for your system tell you to include for the non-standard functions you are
>> using.
>>
>> Of course, if you had asked about this on a group dedicated to your system
>> then the people answering would know if libgen.h was the correct header to
>> include. Here we deal with standard C not extensions provided by specific
>> implementations.
> Actually someone familliar with the error codes returned durring a build,
> and for a particular platform, they can answer this question without seeing
> any code.
> and in the example
> char *pc = fn();
> if you know it should fit then:
> char *pc = (char * ) fn();
> makes it fit.
Looks like clc acquired another troll, top-posting, spewing misin-
formation dangerous for unsuspecting newbies and all...
To the OP: Never, ever mindlessly use a cast just to get rid of a
compiler warning. The warning indicates that the compiler found
something that looks fishy. But by casting you tell the compiler
"Shut up, I know what I am doing, get out of my way". Unless you
really mean it don't do that but try to understand why you get the
warning (and you posted here because you didn't, did you) and what
is the best way to avoid it. Use casts only after you understood
all implications and are sure it's the only and right thing to do.
And here, as "Flesh Gordon" explained perfectly well, a cast is
obviously not necessary (actually, it would be a bad thing to use)
since you only get it when you don't include the header file that
declares the (return type of the) function you're calling.
Regards, Jens
-- \ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de \__________________________ http://www.toerring.de
- Next message: bjrnove: "Re: string array"
- Previous message: Michael Mair: "Re: C FAQ 2.18"
- In reply to: DHOLLINGSWORTH2: "Re: regcmp warning: improper pointer/integer combination: op "=""
- Next in thread: DHOLLINGSWORTH2: "Re: regcmp warning: improper pointer/integer combination: op "=""
- Reply: DHOLLINGSWORTH2: "Re: regcmp warning: improper pointer/integer combination: op "=""
- Reply: Flash Gordon: "Re: regcmp warning: improper pointer/integer combination: op "=""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|