Thread: gcc ignoring defined macros?

gcc ignoring defined macros?

From
"Dave Page"
Date:
Hi all,

This one is really wierd, and as neither Mark or I can figure it out,
maybe one of you knows what's going on!!

Some time ago, I noticed that non-debug builds of pgAdmin on Slackware,
did not pause to display the splash screen as they should. I spent about
2 minutes on the problem, and then moved on as I was busy with work
stuff, and promptly forgot about it.

Yesterday, Keith C. Perry posted a message to the support list stating
that under Slackware, the SSL combo box on frmConnect is empty, so he
was unable to select an SSL mode. First thing I checked was that I
really had built libpq on Snake with SSL support, which I had. I then
checked that pgAdmin was building with the SSL macro defined, which it
was. Finally I added a printf statement inside the #ifdef SSL block that
populates the combobox. That failed to print anything, indicating that
the preprocessor was not including that code.

So, I made a test program:

main() {
#ifdef SSL
    printf("SSL defined.");
#else
    printf("SSL not defined.");
#endif
}

This worked as expected when compiled with or without -DSSL on the g++
commmand line.

So I added some code to the top of pgAdmin3.cpp:

#ifdef SSL
        printf("\nSSL is defined!\n\n");
#else
        printf("\nSSL is not defined!\n\n");
#endif

and recompiled (see below). When running pgAdmin, it prints 'SSL is not
defined'. We're stumped here - any one else have any idea what's going
on?

Cheers, Dave

root@snake:/usr/local/src/pgadmin3-1.0.1# make all
make  all-recursive
make[1]: Entering directory `/usr/local/src/pgadmin3-1.0.1'
Making all in src
make[2]: Entering directory `/usr/local/src/pgadmin3-1.0.1/src'
if g++ -DHAVE_CONFIG_H -I. -I. -I..  -DDATA_DIR=\"/usr/share/pgadmin3/\"
-Wall -g -I../src/include -I -DSSL -I/usr/local/pgsql/include
-I/usr/local/lib/wx/include/gtk2ud-2.5 -D__WXDEBUG__ -D__WXGTK__
-D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -I/usr/local//include
-DDATA_DIR=\"/usr/share/pgadmin3/\" -Wall -g -I../src/include -I -g -O2
-MT pgAdmin3.o -MD -MP -MF ".deps/pgAdmin3.Tpo" \
  -c -o pgAdmin3.o `test -f 'pgAdmin3.cpp' || echo './'`pgAdmin3.cpp; \
then mv ".deps/pgAdmin3.Tpo" ".deps/pgAdmin3.Po"; \
else rm -f ".deps/pgAdmin3.Tpo"; exit 1; \
fi
g++ -DDATA_DIR=\"/usr/share/pgadmin3/\" -Wall -g -I../src/include -I -g
-O2  -L/usr/local/pgsql/lib -L/usr/local//lib -o pgadmin3  pgAdmin3.o
pgConn.o pgSet.o keywords.o pgAggregate.o pgCast.o pgCheck.o
pgCollection.o pgColumn.o pgConstraints.o pgConversion.o pgDatabase.o
pgDomain.o pgForeignKey.o pgFunction.o pgGroup.o pgIndex.o
pgIndexConstraint.o pgLanguage.o pgObject.o pgOperator.o
pgOperatorClass.o pgRule.o pgSchema.o pgSequence.o pgServer.o pgTable.o
pgTrigger.o pgType.o pgUser.o pgView.o pgDatatype.o ctlSQLBox.o
ctlSQLResult.o frmExport.o dlgAddTableView.o events.o frmAbout.o
frmChildTableViewFrame.o frmConnect.o frmMain.o frmOptions.o
frmPassword.o frmQuery.o frmQueryBuilder.o frmHelp.o frmQBJoin.o
frmSplash.o frmMaintenance.o frmEditGrid.o dlgProperty.o dlgUser.o
dlgGroup.o dlgDatabase.o dlgLanguage.o dlgSchema.o dlgDomain.o
dlgTable.o dlgColumn.o dlgIndex.o dlgFunction.o dlgView.o dlgRule.o
dlgOperator.o dlgAggregate.o dlgCast.o dlgConversion.o
dlgIndexConstraint.o dlgForeignKey.o dlgSequence.o dlgTrigger.o
dlgType.o dlgCheck.o frmStatus.o misc.o sysLogger.o sysSettings.o
xrcDialogs.o  /usr/local/pgsql/lib/libpq.a -lcrypt  -lssl -lcrypto
/usr/local//lib/libwx_gtk2ud_stc-2.5.a
/usr/local//lib/libwx_gtk2ud_xrc-2.5.a -L/usr/local/lib -pthread
/usr/local/lib/libwx_gtk2ud-2.5.a -Wl,--export-dynamic -pthread
-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm
-lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl
-lgthread-2.0 -lglib-2.0 -Wl,--export-dynamic -lpangoft2-1.0 -lpango-1.0
-lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lpng -ljpeg -ltiff -lz -ldl
-lm
make[2]: Leaving directory `/usr/local/src/pgadmin3-1.0.1/src'
make[2]: Entering directory `/usr/local/src/pgadmin3-1.0.1'
make[2]: Nothing to be done for `all-am'.

Re: gcc ignoring defined macros?

From
"Hiroshi Saito"
Date:
Ooops..
It was a problem even with FreeBSD.
Confirmation was neglected.!!
Why??

regards,
Hiroshi Saito

From: "Dave Page" <dpage@vale-housing.co.uk>


> Hi all,

(snip)
> and recompiled (see below). When running pgAdmin, it prints 'SSL is not
> defined'. We're stumped here - any one else have any idea what's going
> on?


Re: gcc ignoring defined macros?

From
"Dave Page"
Date:

> -----Original Message-----
> From: Hiroshi Saito [mailto:saito@inetrt.skcapi.co.jp]
> Sent: 02 October 2003 11:55
> To: Dave Page
> Cc: pgadmin-hackers@postgresql.org
> Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?
>
>
> Ooops..
> It was a problem even with FreeBSD.
> Confirmation was neglected.!!
> Why??

What gcc do you have? I forgot to mention I have 3.2.2.

Regards, Dave.

Re: gcc ignoring defined macros?

From
"Hiroshi Saito"
Date:
It is 3.2.2.

bsd5% gcc -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.2.2 [FreeBSD] 20030205 (release)

regards,
Hiroshi Saito

----- Original Message -----
From: "Dave Page" <dpage@vale-housing.co.uk>

> -----Original Message-----
> From: Hiroshi Saito [mailto:saito@inetrt.skcapi.co.jp]
> Sent: 02 October 2003 11:55
> To: Dave Page
> Cc: pgadmin-hackers@postgresql.org
> Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?
>
>
> Ooops..
> It was a problem even with FreeBSD.
> Confirmation was neglected.!!
> Why??

What gcc do you have? I forgot to mention I have 3.2.2.

Regards, Dave.

Re: gcc ignoring defined macros?

From
"Hiroshi Saito"
Date:
Hi Dave

A cause is this.

pg_config.h:#define HAVE_LIBSSL 1
pg_config.h:/* Define to build with (Open)SSL support. (--with-openssl) */
pg_config.h:#define USE_SSL 1

ssl.h
SSL define...

Is there a problem in -DSSL?

regards,
Hiroshi Saito

----- Original Message -----
From: "Hiroshi Saito" <saito@inetrt.skcapi.co.jp>
To: "Dave Page" <dpage@vale-housing.co.uk>
Cc: <pgadmin-hackers@postgresql.org>
Sent: Thursday, October 02, 2003 8:05 PM
Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?


> It is 3.2.2.
>
> bsd5% gcc -v
> Using built-in specs.
> Configured with: FreeBSD/i386 system compiler
> Thread model: posix
> gcc version 3.2.2 [FreeBSD] 20030205 (release)
>
> regards,
> Hiroshi Saito
>
> ----- Original Message -----
> From: "Dave Page" <dpage@vale-housing.co.uk>
>
> > -----Original Message-----
> > From: Hiroshi Saito [mailto:saito@inetrt.skcapi.co.jp]
> > Sent: 02 October 2003 11:55
> > To: Dave Page
> > Cc: pgadmin-hackers@postgresql.org
> > Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?
> >
> >
> > Ooops..
> > It was a problem even with FreeBSD.
> > Confirmation was neglected.!!
> > Why??
>
> What gcc do you have? I forgot to mention I have 3.2.2.
>
> Regards, Dave.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings

Re: gcc ignoring defined macros?

From
"Dave Page"
Date:

> -----Original Message-----
> From: Hiroshi Saito [mailto:saito@inetrt.skcapi.co.jp]
> Sent: 02 October 2003 12:23
> To: Dave Page
> Cc: pgadmin-hackers@postgresql.org
> Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?
>
>
> Hi Dave
>
> A cause is this.
>
> pg_config.h:#define HAVE_LIBSSL 1
> pg_config.h:/* Define to build with (Open)SSL support.
> (--with-openssl) */ pg_config.h:#define USE_SSL 1
>
> ssl.h
> SSL define...
>
> Is there a problem in -DSSL?

I don't think it's an SSL problem, because it seems to ignore
__WXDEBUG__ as well.

Regards, Dave.

Re: gcc ignoring defined macros?

From
"Dave Page"
Date:
Hi Adam,
 
Tried that in frmConnect, and the SSL combo box is correctly populated, so the preprocessor is working, just not seeing the externally defined macros. by the sound of it.
 
Regards, Dave.
-----Original Message-----
From: Adam H. Pendleton [mailto:fmonkey@fmonkey.net]
Sent: 02 October 2003 15:04
To: Dave Page
Cc: Hiroshi Saito; pgadmin-hackers@postgresql.org
Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?

Dave Page wrote:
I don't think it's an SSL problem, because it seems to ignore
__WXDEBUG__ as well.
 
What is the behavior if you add an explicit "#define SSL 1" before the #ifdef?

ahp

Re: gcc ignoring defined macros?

From
"Adam H. Pendleton"
Date:
Dave Page wrote:
I don't think it's an SSL problem, because it seems to ignore
__WXDEBUG__ as well.
 
What is the behavior if you add an explicit "#define SSL 1" before the #ifdef?

ahp

Re: gcc ignoring defined macros?

From
"Hiroshi Saito"
Date:
MessageHmm...

I am in confusion.
The one related to the reference of include was not a problem certainly.
define is done forcibly now.?
Oh..It is wrong....
I must think what you should do.

regards,
Hiroshi Saito

----- Original Message -----
From: Dave Page
To: Adam H. Pendleton
Cc: Hiroshi Saito ; pgadmin-hackers@postgresql.org
Sent: Thursday, October 02, 2003 11:08 PM
Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?


Hi Adam,

Tried that in frmConnect, and the SSL combo box is correctly populated, so the preprocessor is working, just not seeing
the
externally defined macros. by the sound of it.

Regards, Dave.
-----Original Message-----
From: Adam H. Pendleton [mailto:fmonkey@fmonkey.net]
Sent: 02 October 2003 15:04
To: Dave Page
Cc: Hiroshi Saito; pgadmin-hackers@postgresql.org
Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?


Dave Page wrote:


I don't think it's an SSL problem, because it seems to ignore
__WXDEBUG__ as well.


What is the behavior if you add an explicit "#define SSL 1" before the #ifdef?

ahp


Re: gcc ignoring defined macros?

From
"Hiroshi Saito"
Date:
<Sigh>
Make was done as much as to be innumerable today...
It doesn't know problem.

The mood of the machine is ill today.
To the bed.:-)

regards,
Hiroshi Saito


Re: gcc ignoring defined macros?

From
Adam H.Pendleton
Date:
On Thursday, Oct 2, 2003, at 10:08 US/Eastern, Dave Page wrote:

> Hi Adam,
>  
> Tried that in frmConnect, and the SSL combo box is correctly
> populated, so the preprocessor is working, just not seeing the
> externally defined macros. by the sound of it.
>  
> Regards, Dave.
>
>

How are you adding the -DSSL flag to the command line?  It might be
mistaken for a linker flag because of its location in the args.  Just a
shot in the dark, really...

ahp

Re: gcc ignoring defined macros?

From
"Dave Page"
Date:

> -----Original Message-----
> From: Adam H. Pendleton [mailto:fmonkey@fmonkey.net]
> Sent: 02 October 2003 23:29
> To: Dave Page
> Cc: Hiroshi Saito; pgadmin-hackers@postgresql.org
> Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?
>
>
>
> How are you adding the -DSSL flag to the command line?  It might be
> mistaken for a linker flag because of its location in the
> args.  Just a
> shot in the dark, really...

Ah-ha!!

Right, I editted the line in src/Makefile that compiles frmConnect.cpp.
I added -DSSL so the final command read:

if g++ -DSSL -DHAVE_CONFIG_H -I. ........

And that works. :-)

Further investigation of the command line:

if g++ -DHAVE_CONFIG_H -I. -I. -I..
-DDATA_DIR=\"/usr/local/pgadmin3/share/pgadmin3/\" -Wall -g
-I../src/include -I../src/agent/include -I -DSSL
-I/usr/local/pgsql/include -I/usr/local/lib/wx/include/gtk2ud-2.5
-D__WXDEBUG__ -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
-I/usr/local/include -DDATA_DIR=\"/usr/local/pgadmin3/share/pgadmin3/\"
-Wall -g -I../src/include -I../src/agent/include -I -g -O2 -MT
frmConnect.o -MD -MP -MF ".deps/frmConnect.Tpo" \
  -c -o frmConnect.o `test -f 'ui/frmConnect.cpp' || echo
'./'`ui/frmConnect.cpp; \
then mv ".deps/frmConnect.Tpo" ".deps/frmConnect.Po"; \
else rm -f ".deps/frmConnect.Tpo"; exit 1; \
fi

shows up the problem. Firstly, a bunch of it seems to be included twice.
Note the double inclusion of:

-DDATA_DIR=\"/usr/local/pgadmin3/share/pgadmin3/\" -Wall -g
-I../src/include -I../src/agent/include -I

Then secondly, notice the -I on the end which does not have a path -
that's what seems to be losing the SSL definition because it gets picked
up as the argument to -I. Further investigation shows that that path is
set to ${WXHOME} which is ovbviously empty when the command is created.
Adding a / to the end of it makes things work nicely.

Not sure about the best way to fix this properly, so I guess it's over
to you Adam :-)

Regards, Dave.

Re: gcc ignoring defined macros?

From
"Adam H. Pendleton"
Date:
Dave Page wrote:
Ah-ha!!

Right, I editted the line in src/Makefile that compiles frmConnect.cpp.
I added -DSSL so the final command read:

if g++ -DSSL -DHAVE_CONFIG_H -I. ........

And that works. :-)

Further investigation of the command line:

if g++ -DHAVE_CONFIG_H -I. -I. -I..
-DDATA_DIR=\"/usr/local/pgadmin3/share/pgadmin3/\" -Wall -g
-I../src/include -I../src/agent/include -I -DSSL
-I/usr/local/pgsql/include -I/usr/local/lib/wx/include/gtk2ud-2.5
-D__WXDEBUG__ -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
-I/usr/local/include -DDATA_DIR=\"/usr/local/pgadmin3/share/pgadmin3/\"
-Wall -g -I../src/include -I../src/agent/include -I -g -O2 -MT
frmConnect.o -MD -MP -MF ".deps/frmConnect.Tpo" \ -c -o frmConnect.o `test -f 'ui/frmConnect.cpp' || echo
'./'`ui/frmConnect.cpp; \
then mv ".deps/frmConnect.Tpo" ".deps/frmConnect.Po"; \
else rm -f ".deps/frmConnect.Tpo"; exit 1; \
fi

shows up the problem. Firstly, a bunch of it seems to be included twice.
Note the double inclusion of:

-DDATA_DIR=\"/usr/local/pgadmin3/share/pgadmin3/\" -Wall -g
-I../src/include -I../src/agent/include -I

Then secondly, notice the -I on the end which does not have a path -
that's what seems to be losing the SSL definition because it gets picked
up as the argument to -I. Further investigation shows that that path is
set to ${WXHOME} which is ovbviously empty when the command is created.
Adding a / to the end of it makes things work nicely.

Not sure about the best way to fix this properly, so I guess it's over
to you Adam :-)

Regards, Dave.
 
I was about to fix this, when I realized that I was about to add -DSSL to the command-line for *all* situations.  Is this what we want, or is this supposed to be a conditional compile option?  If it's needed for *all* situations, then why included it at all, why not just remove the #ifdefs and always compile the SSL code?

ahp

Re: gcc ignoring defined macros?

From
"Hiroshi Saito"
Date:
Hi Adam.

IMHO,
libpq (PostgreSQL) becomes Non SSL if designation (--with-openssl) isn't done.
It isn't used even if it has SSL-Library.
Because libpq is used, pgAdmin3 is thought to be an option.
However,
I think that we will force to use it.

regards,
Hiroshi Saito

From: Adam H. Pendleton
(snip)

> I was about to fix this, when I realized that I was about to add -DSSL to the command-line for *all*
> situations.  Is this what we want,
> or is this supposed to be a conditional compile option?
> If it's needed for *all* situations, then why included it at all,
> why not just >remove the #ifdefs and always compile the SSL code?


Re: gcc ignoring defined macros?

From
"Dave Page"
Date:
 
-----Original Message-----
From: Adam H. Pendleton [mailto:fmonkey@fmonkey.net]
Sent: 06 October 2003 18:26
To: Dave Page
Cc: Hiroshi Saito; pgadmin-hackers@postgresql.org
Subject: Re: [pgadmin-hackers] gcc ignoring defined macros?

Dave Page wrote: 
 
 I was about to fix this, when I realized that I was about to add -DSSL to the command-line for *all* situations.  Is this what we want, or is this supposed to be a conditional compile option?  If it's needed for *all* situations, then why included it at all, why not just remove the #ifdefs and always compile the SSL code?
 
We should probably include it as an option as not everyone compiles PostgreSQL with SSL support (I normally don't for example). Can it be done automagically by looking for the SSL_connect symbol in libpq.a/libpq.so?
 
Regards, Dave.