Discussion:
incompatible integer to pointer conversion
(too old to reply)
Chris
2024-05-23 21:40:59 UTC
Permalink
Sorry, this is really a basic "programming in C 101" question.
But for the life of me, I'm not getting it. The source in
question:

LDAP *setup_ldap()
{
LDAP *ret;
int n;

if (debug) fprintf(stderr, "radldap: Setting up LDAP for %s, port %d\n",
host, port);
if (!(ret = ldap_init(host, port))) {
fprintf(stderr, "radldap: Could not initialize LDAP!\n");
_exit(2);
}

Now *you* can probably already see the problem. But this is what's returned:

radldap.c:302:12: error: incompatible integer to pointer conversion assigning
to 'LDAP *' (aka 'struct ldap *') from 'int' [-Wint-conversion]
302 | if (!(ret = ldap_init(host, port))) {
| ^ ~~~~~~~~~~~~~~~~~~~~~

Thanks in advance for any hints, or pointers.


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Brooks Davis
2024-05-23 21:50:38 UTC
Permalink
Post by Chris
Sorry, this is really a basic "programming in C 101" question.
But for the life of me, I'm not getting it. The source in
LDAP *setup_ldap()
{
LDAP *ret;
int n;
if (debug) fprintf(stderr, "radldap: Setting up LDAP for %s, port %d\n",
host, port);
if (!(ret = ldap_init(host, port))) {
fprintf(stderr, "radldap: Could not initialize LDAP!\n");
_exit(2);
}
radldap.c:302:12: error: incompatible integer to pointer conversion assigning
to 'LDAP *' (aka 'struct ldap *') from 'int' [-Wint-conversion]
302 | if (!(ret = ldap_init(host, port))) {
| ^ ~~~~~~~~~~~~~~~~~~~~~
Thanks in advance for any hints, or pointers.
Have you included ldap.h? Are there any warnings about implicit
declarations?

-- Brooks


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Cy Schubert
2024-05-23 22:09:38 UTC
Permalink
Post by Brooks Davis
Post by Chris
Sorry, this is really a basic "programming in C 101" question.
But for the life of me, I'm not getting it. The source in
LDAP *setup_ldap()
{
LDAP *ret;
int n;
if (debug) fprintf(stderr, "radldap: Setting up LDAP for %s, port %d\n"
,
Post by Chris
host, port);
if (!(ret = ldap_init(host, port))) {
fprintf(stderr, "radldap: Could not initialize LDAP!\n");
_exit(2);
}
Now *you* can probably already see the problem. But this is what's returned
radldap.c:302:12: error: incompatible integer to pointer conversion assigni
ng
Post by Chris
to 'LDAP *' (aka 'struct ldap *') from 'int' [-Wint-conversion]
302 | if (!(ret = ldap_init(host, port))) {
| ^ ~~~~~~~~~~~~~~~~~~~~~
Thanks in advance for any hints, or pointers.
Have you included ldap.h? Are there any warnings about implicit
declarations?
ldap.h includes this as well:

#if LDAP_DEPRECATED
LDAP_F( LDAP * )
ldap_init LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
LDAP_CONST char *host,
int port ));

LDAP_F( LDAP * )
ldap_open LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
LDAP_CONST char *host,
int port ));
#endif

Apps such as dovecot and apr-1 have,

#define LDAP_DEPRECATED 1
Post by Brooks Davis
-- Brooks
--
Cheers,
Cy Schubert <***@cschubert.com>
FreeBSD UNIX: <***@FreeBSD.org> Web: https://FreeBSD.org
NTP: <***@nwtime.org> Web: https://nwtime.org

e^(i*pi)+1=0




--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Chris
2024-05-23 22:28:13 UTC
Permalink
Post by Cy Schubert
Post by Brooks Davis
Post by Chris
Sorry, this is really a basic "programming in C 101" question.
But for the life of me, I'm not getting it. The source in
LDAP *setup_ldap()
{
LDAP *ret;
int n;
if (debug) fprintf(stderr, "radldap: Setting up LDAP for %s, port %d\n"
,
Post by Chris
host, port);
if (!(ret = ldap_init(host, port))) {
fprintf(stderr, "radldap: Could not initialize LDAP!\n");
_exit(2);
}
Now *you* can probably already see the problem. But this is what's returned
radldap.c:302:12: error: incompatible integer to pointer conversion assigni
ng
Post by Chris
to 'LDAP *' (aka 'struct ldap *') from 'int' [-Wint-conversion]
302 | if (!(ret = ldap_init(host, port))) {
| ^ ~~~~~~~~~~~~~~~~~~~~~
Thanks in advance for any hints, or pointers.
Have you included ldap.h? Are there any warnings about implicit
declarations?
#if LDAP_DEPRECATED
LDAP_F( LDAP * )
ldap_init LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
LDAP_CONST char *host,
int port ));
LDAP_F( LDAP * )
ldap_open LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
LDAP_CONST char *host,
int port ));
#endif
Apps such as dovecot and apr-1 have,
#define LDAP_DEPRECATED 1
Heh. Based on the volumes of warns I'm seeing, I can understand why. My
"quick fix" just turned into a bit of a project. :(

Thanks for the pointer, Cy. Greatly appreciated!
Post by Cy Schubert
Post by Brooks Davis
-- Brooks
--Chris


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Chris
2024-05-23 23:12:58 UTC
Permalink
Post by Chris
Post by Cy Schubert
Post by Brooks Davis
Post by Chris
Sorry, this is really a basic "programming in C 101" question.
But for the life of me, I'm not getting it. The source in
LDAP *setup_ldap()
{
LDAP *ret;
int n;
if (debug) fprintf(stderr, "radldap: Setting up LDAP for %s, port %d\n"
,
Post by Chris
host, port);
if (!(ret = ldap_init(host, port))) {
fprintf(stderr, "radldap: Could not initialize LDAP!\n");
_exit(2);
}
Now *you* can probably already see the problem. But this is what's returned
radldap.c:302:12: error: incompatible integer to pointer conversion assigni
ng
Post by Chris
to 'LDAP *' (aka 'struct ldap *') from 'int' [-Wint-conversion]
302 | if (!(ret = ldap_init(host, port))) {
| ^ ~~~~~~~~~~~~~~~~~~~~~
Thanks in advance for any hints, or pointers.
Have you included ldap.h? Are there any warnings about implicit
declarations?
#if LDAP_DEPRECATED
LDAP_F( LDAP * )
ldap_init LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
LDAP_CONST char *host,
int port ));
LDAP_F( LDAP * )
ldap_open LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */
LDAP_CONST char *host,
int port ));
#endif
Apps such as dovecot and apr-1 have,
#define LDAP_DEPRECATED 1
Heh. Based on the volumes of warns I'm seeing, I can understand why. My
Well FWIW. I used the define you pointed at, and all's well for my current
task. Case closed.

Thanks again, Cy && Brooks!
Post by Chris
Thanks for the pointer, Cy. Greatly appreciated!
Post by Cy Schubert
Post by Brooks Davis
-- Brooks
--Chris
--Chris


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Chris
2024-05-23 22:09:05 UTC
Permalink
Post by Brooks Davis
Post by Chris
Sorry, this is really a basic "programming in C 101" question.
But for the life of me, I'm not getting it. The source in
LDAP *setup_ldap()
{
LDAP *ret;
int n;
if (debug) fprintf(stderr, "radldap: Setting up LDAP for %s, port %d\n",
host, port);
if (!(ret = ldap_init(host, port))) {
fprintf(stderr, "radldap: Could not initialize LDAP!\n");
_exit(2);
}
radldap.c:302:12: error: incompatible integer to pointer conversion assigning
to 'LDAP *' (aka 'struct ldap *') from 'int' [-Wint-conversion]
302 | if (!(ret = ldap_init(host, port))) {
| ^ ~~~~~~~~~~~~~~~~~~~~~
Thanks in advance for any hints, or pointers.
Have you included ldap.h?
Are there any warnings about implicit declarations?
Yep. Loads of them. That's what I needed. I've got it now.

Thanks a million for the reply, Brooks.
Post by Brooks Davis
-- Brooks
--Chris


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...