473,472 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

regcmp warning: improper pointer/integer combination: op "="


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 ?

Thanks,
Jose Luis.

Nov 14 '05 #1
16 5792
jo**********************@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 ?

Thanks,
Jose Luis.


In C all functions return an int if the prototype is not known to the
compiler.

If you have a function that returns a pointer like:

char *fn(void);

you can do this in your code without problems:

char *a = fn();

Now, if the compiler doesn't see the prototype, the fn function is
assumed to return an integer, that gets assigned to char char pointer
a. Assignment of an integer to a pointer is not a very good idea,
even if "it works", so the compiler warns you about it.

Solution:

DO INCLUDE all necessary header files when compiling.

jacob
Nov 14 '05 #2
jo**********************@yahoo.es wrote:

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 ?


There is no such standard include file in C, nor is there any such
routine as regcmp. You will have to show the code for these to
receive any reasonable answer.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson

Nov 14 '05 #3
jo**********************@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.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #4
On Tue, 08 Mar 2005 14:31:21 GMT, in comp.lang.c , CBFalconer
<cb********@yahoo.com> wrote:
jo**********************@yahoo.es wrote:

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 ?


There is no such standard include file in C, nor is there any such
routine as regcmp. You will have to show the code for these to
receive any reasonable answer.


No he doesn't - its perfectly possible to explain this without knowing
anything outside Standard C. Indeed jacob navia's answer was it.

CBF this is about the nth time you've unjustly posted in this vein. Is it
worth stepping back from the keyboard for a couple of days?

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 14 '05 #5
Mark McIntyre wrote:
<cb********@yahoo.com> wrote:
jo**********************@yahoo.es wrote:

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 ?


There is no such standard include file in C, nor is there any such
routine as regcmp. You will have to show the code for these to
receive any reasonable answer.


No he doesn't - its perfectly possible to explain this without
knowing anything outside Standard C. Indeed jacob navia's answer
was it.

CBF this is about the nth time you've unjustly posted in this
vein. Is it worth stepping back from the keyboard for a couple
of days?


Color me stoopid, but I don't see any such diagnosis. It is just
one of many possibilities, and nobody can tell without seeing the
source.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #6
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.

"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:l8************@brenda.flash-gordon.me.uk...
jo**********************@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.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.

Nov 14 '05 #7
DHOLLINGSWORTH2 <DH*************@cox.net> wrote:
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:l8************@brenda.flash-gordon.me.uk...
jo**********************@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 ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #8
I'm glad to see that you DO agree with me on one or two points.

It's too bad you like to hear it from your own mouth.

As far as missinformation goes I've been writting programs since 1986.

And although you may not be familiar with a product, doesn't mean every body
else is just as ignorant.

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
Actually I agreed with the man that he doesn't need to see the code. And
aparently you, who hasn't seen the code, agrees with both of us.
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
Is this not what I just said?

spewing misin-
formation dangerous for unsuspecting newbies and all...
You have confirmed every bit of information I spewed.
Thank you.
Looks like clc acquired another troll, top-posting,


Stick it in your ass!
Nov 14 '05 #9
DHOLLINGSWORTH2 wrote:
I'm glad to see that you DO agree with me on one or two points.

It's too bad you like to hear it from your own mouth.

As far as missinformation goes I've been writting programs since 1986.
That does not mean that you actually know what you are talking about or
that you are not giving misinformation.
And although you may not be familiar with a product, doesn't mean every body
else is just as ignorant.


This group does not deal with implementation specifics. There are plenty
of groups that do.

I happen to believe the CBF was over zealous since I believe a good
indication could be obtained from the diagnostic without knowing the
specific implementation. However, note that I still considered it worth
redirecting the OP because the function in question *is* on-standard so
it is only the diagnostic that gives us a clue as to what the problem was.
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


Actually I agreed with the man that he doesn't need to see the code. And
aparently you, who hasn't seen the code, agrees with both of us.


I was able to take a good guess and based on that give a standard C
answer about the probable problem. However, there are likely to be other
problems that the OP needs to address that we can't do here.
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


Is this not what I just said?


When a function actually returns a pointer, casting to get rid of the
warning due to not having the declaration in scope is NEVER the right
thing to do. As I almost said to the OP (but thought it too much
information) you actually invoke undefined behaviour and one REAL way
this fails on some implementations is the address being returned in
register A0 but the compiler reading from D0 (because it thinks an
integer is returned) and so storing garbage in the pointer variable
whilst ignoring the real pointer value. So whether you know "it should
fit" is not the question, the question is whether the compiler knows the
real return type. Also, I cannot think of any instances where it is
appropriate to have a function actually return an int and the program
then cast that to a pointer type and store it in a pointer.
spewing misin-
formation dangerous for unsuspecting newbies and all...


You have confirmed every bit of information I spewed.
Thank you.


No, you suggested that casting might be an appropriate solution. It is
definitely NOT the correct solution.

<OT>
regcmp declared in libgen.h *does* return a pointer to char, so casting
would definitely invoke undefined behaviour and almost certainly cause
the program to fail on some real *nix implementations, it almost
certainly being a *nix program.
</OT>
Looks like clc acquired another troll, top-posting,


Stick it in your ass!


The *only* reason I'm not plonking you is that any further
misinformation you spew needs to be corrected to try to prevent people
who do not know any better from believing you.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #10
Je***********@physik.fu-berlin.de wrote:
DHOLLINGSWORTH2 <DH*************@cox.net> wrote:
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:l8************@brenda.flash-gordon.me.uk...

<snip>
And here, as "Flesh Gordon" explained perfectly well, a cast is


Actually, it is Flash Gordon. Flesh Gordon is my dirty minded twin :-)
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #11
Flash Gordon <sp**@flash-gordon.me.uk> wrote:
Je***********@physik.fu-berlin.de wrote:
DHOLLINGSWORTH2 <DH*************@cox.net> wrote:
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:l8************@brenda.flash-gordon.me.uk...
<snip> And here, as "Flesh Gordon" explained perfectly well, a cast is

Actually, it is Flash Gordon. Flesh Gordon is my dirty minded twin :-)


Oh, sorry. Didn't mean to do that (but I plead innocence, I had to
google to find out what's the difference between you two;-)

Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #12
"DHOLLINGSWORTH2" <DH*************@cox.net> wrote:
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:l8************@brenda.flash-gordon.me.uk...
jo**********************@yahoo.es wrote:
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.

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.
Which is exactly what Mr. Gordon did, and correctly, which is more than
can be said for your answer.
and in the example

char *pc = fn();

if you know it should fit then:

char *pc = (char * ) fn();

makes it fit.


No, it doesn't. If there is no declaration for fn() in scope, the
implementation assumes it returns int. Casting this int to char * may,
but need not, result in the char * that was originally returned from
fn().
If, for example, the implementation optimises function calls by
returning scalars in registers rather than on the stack, and by using
separate address and integer registers where available, your cast is
going to result in a lot of random garbage being returned.

Just provide a proper declaration for all your functions, if at all
possible by #including the appropriate headers, and you'll never have to
worry about such bogus casts again.

Richard
Nov 14 '05 #13
Je***********@physik.fu-berlin.de wrote:
Flash Gordon <sp**@flash-gordon.me.uk> wrote:
Je***********@physik.fu-berlin.de wrote:
DHOLLINGSWORTH2 <DH*************@cox.net> wrote:

"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:l8************@brenda.flash-gordon.me.uk...
<snip>

And here, as "Flesh Gordon" explained perfectly well, a cast is

Actually, it is Flash Gordon. Flesh Gordon is my dirty minded twin :-)


Oh, sorry. Didn't mean to do that (but I plead innocence, I had to
google to find out what's the difference between you two;-)


Just as long as you did not do the googling from work. Your employer
might not understand ;-)
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #14
And I could pretend to be an ass and say that none of youtr examples work
becuase they have no main proc in them.

And I may be wrong, but Type casting is a no no, then why is it in the
STANDARD?

Bullocks
Nov 14 '05 #15
DHOLLINGSWORTH2 wrote:
And I could pretend to be an ass and say that none of youtr examples work
becuase they have no main proc in them.
Please quote enough of the message you refer to for those of us who
might not (yet) have found it yet on their newsservers.

And I may be wrong, but Type casting is a no no, then why is it in the
STANDARD?
As I do not know what you are referring to:
Typecasting is only necessary if the implicit conversions do not
or cannot achieve what you are trying to do. It is good style to
use typecasts only when they are necessary or, very seldom, when
they clarify your intent. The latter is almost never helpful, thus
"very seldom".
Unnecessary typecasting may lead to equally unnecessary errors or
misinterpretations, so one should avoid it.

Some examples where you may need typecasts:
- null pointer constants as arguments to variadic functions
- enforcing a certain precision for the result of a floating point
computation
- giving the left operand of a left shift the necessary width
- ...

Bullocks


I understand that this is either an unfortunate first name or a very
honest qualification of your writings or a very unfriendly closing
for your message.
None of that does look good for you.
- Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #16
"DHOLLINGSWORTH2" <DH*************@cox.net> writes:
And I could pretend to be an ass and say that none of youtr examples work
becuase they have no main proc in them.

And I may be wrong, but Type casting is a no no, then why is it in the
STANDARD?


Type casting is in the standard because there are cases where it can
be used correctly and usefully. For example, if you want have a
pointer-to-int variable and you want to show its value, you can use:

int *ptr = <whatever>;
printf("ptr = %p\n", (void*)ptr);

This cast is necessary and appropriate because the call to printf()
doesn't provide a context that forces an implicit conversion.

In most other cases, though, C's implicit conversion rules make casts
unnecessary (and often dangerous).

The OP was asking about an implementation-defined function that
returns a char*; an implementation-defined header provides a prototype
for the function. If the header is not included, the compiler sees a
call and doesn't know what type it returns. In C90, the language
requires the compiler to assume (incorrectly in this case) that it
returns int, so it will generate code that assumes this. Casting the
result to char* doesn't fix the problem, it hides it. The result is
that the compiler generates code takes the (potentially nonexistent)
int result of the function and converts it to char*. This may happen
to work on some systems, but will fail on others.

For the call to work properly, the compiler must know that the
function returns a char*. The way to do this is to include the header
(or to declare the function explicitly, but it's almost always better
to include the header).

Your response suggested that casting the result would be a solution.
You were mistaken. Several people pointed out your error. This is
not being an "ass"; indeed, leaving your error uncorrected would have
been rude to you and to all the readers who might follow your advice.

Making mistakes isn't a horrible sin. I've made plenty myself, and
I'm glad when they're corrected. If someone points out that you've
made a mistake, don't take it personally.

And if you want to be taken seriously, I strongly suggest you stop
top-posting. We're not asking you this just to be annoying; your
posting style really does make your articles more difficult to read.
You've already been told in detail why top-posting is a bad idea.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: python | last post by:
Hi- I'm getting a "DeprecationWarning: integer argument expected, got float" warning with mx.DateTime and I can't figure out why. Can anyone help me out? This code: import mx.DateTime
2
by: Liang | last post by:
Hi, I use "defined $r_libs->{$name}" to check first if a key exists in a hash table. But Perl gives a warning WHENEVER the key exists: "Use of uninitialized value". Would u please help to...
6
by: murgan | last post by:
Hi people, i am new to this group,this is my first query, friends i want to know the difference between "function pointer" and "pointer to a function" in c lang, so friends please send the...
1
by: TC | last post by:
Every time I open my project, I get a warning which says "There are updated custom wrappers available for the following referenced components: Office." When I double-click on the warning, I get...
2
by: Bill_DBA | last post by:
I have the following stored procedure that is called from the source of a transformation in a DTS package. The first parameter turns on PRINT debug messages. The second, when equals 1, turns on the...
1
by: =?Utf-8?B?TWlraGFpbCBHb2xvdm55a2g=?= | last post by:
Hi, I keep getting compilier warnings like this: At least one of the arguments for '-----' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer...
1
by: pbaldridge | last post by:
I'm trying to code a simple function that will prompt a user if they want to see another set of problems. The error I receive is "ANSI C++ forbids comparison between pointer and integer" int...
4
by: Wayne | last post by:
How do I get rid of the generic Windows "Open File - Security Warning" that appears when I try to open a database that resides on another PC on my home network? This is not the annoying macro...
5
by: Torben Laursen | last post by:
I am writing a COM in C# using visual studio 2005 and VSTO. Inside the code I use some support classes that are generic but they are not used in the inferface of the COM. However I still get a...
20
by: chutsu | last post by:
I'm trying to compare between pointer and integer in an "IF" statement how do I make this work? if(patient.id != NULL){ } Thanks Chris
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.