unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Double slashes in config.h
@ 2005-03-20  5:43 Lőrentey Károly
  2005-03-20 18:01 ` Richard Stallman
  0 siblings, 1 reply; 7+ messages in thread
From: Lőrentey Károly @ 2005-03-20  5:43 UTC (permalink / raw)



[-- Attachment #1.1.1: Type: text/plain, Size: 2003 bytes --]

Hi,

trying to investigate some problems with GTK + multi-tty, I wanted to
compile Emacs with a debuggable GTK version.  I was weary but not
entirely shocked to find out that Emacs failed to pick up the location
of my locally compiled GTK instance.  Here is my pkg-config output for GTK:

$ pkg-config gtk+-2.0 --cflags
-DXTHREADS -I/home/lorentey/work/emacs/install//include/gtk-2.0 \
-I/home/lorentey/work/emacs/install//lib/gtk-2.0/include \
-I/usr/X11R6/include \
-I/home/lorentey/work/emacs/install//include/atk-1.0 \
-I/home/lorentey/work/emacs/install//include/pango-1.0 \
-I/usr/include/freetype2 \
-I/home/lorentey/work/emacs/install//include/cairo \
-I/home/lorentey/work/emacs/install//include -I/usr/include/libpng12 \
-I/home/lorentey/work/emacs/install/include/glib-2.0 \
-I/home/lorentey/work/emacs/install/lib/glib-2.0/include  

Note the double slashes; these are caused by ending a --prefix with a
slash, and are normally harmless.  In this case, however, the paths
are run through cpp, which thinks that the double slashes start
one-line comments.  The result is that pkg-config's carefully
configured include options are harshly truncated in src/Makefile:

ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. -I${srcdir} -D_BSD_SOURCE -I/usr/X11R6/include -DXTHREADS -I/home/lorentey/work/emacs/install ${CFLAGS}

For reference, here are the corresponding lines in src/Makefile.in:

/* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM
   since it may have -I options that should override those two.  */
ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAGS) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM C_SWITCH_SYSTEM_TEMACS ${CFLAGS}

Passing the -ansi option to (GNU) cpp disables `//' recognition.  To
prevent other people running into this same problem, I think it would
be useful to apply the following patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: Type: text/x-patch, Size: 1411 bytes --]

--- orig/configure.in
+++ mod/configure.in
@@ -3126,6 +3126,14 @@
 	CPP_NEED_TRADITIONAL=no,
 	CPP_NEED_TRADITIONAL=yes)
 
+## New-fangled C preprocessors consider `//' to start a one-line comment.
+## The -ansi option forces GCC's cpp to ignore this syntax.
+
+AC_EGREP_CPP(yes//yes,
+	[yes//yes],
+	CPP_NEED_ANSI=no,
+	CPP_NEED_ANSI=yes)
+
 AC_OUTPUT(Makefile lib-src/Makefile.c:lib-src/Makefile.in oldXMenu/Makefile \
 	man/Makefile lwlib/Makefile src/Makefile.c:src/Makefile.in \
 	lisp/Makefile lispref/Makefile lispintro/Makefile leim/Makefile, [
@@ -3160,6 +3168,13 @@
   CPPFLAGS="$CPPFLAGS -traditional"
 fi
 
+# Recent GNU cpp versions understand C++-style one-line comments
+# unless invoked with -ansi.  (Works with GCC 3.3, 3.4, 4.0)
+
+if test "x$GCC" = xyes && test "x$CPP_NEED_ANSI" = xyes; then
+  CPPFLAGS="$CPPFLAGS -ansi"
+fi
+
 echo creating lib-src/Makefile
 ( cd lib-src
   rm -f junk.c junk1.c junk2.c
@@ -3200,7 +3215,7 @@
 # This is how we know whether to re-run configure in certain cases.
 touch src/config.stamp
 
-], [GCC="$GCC" NON_GNU_CPP="$NON_GNU_CPP" CPP="$CPP" CPP_NEED_TRADITIONAL="$CPP_NEED_TRADITIONAL" CPPFLAGS="$CPPFLAGS"])
+], [GCC="$GCC" NON_GNU_CPP="$NON_GNU_CPP" CPP="$CPP" CPP_NEED_TRADITIONAL="$CPP_NEED_TRADITIONAL" CPP_NEED_ANSI="$CPP_NEED_ANSI" CPPFLAGS="$CPPFLAGS"])
 
 m4_if(dnl	Do not change this comment
    arch-tag: 156a4dd5-bddc-4d18-96ac-f37742cf6a5e



[-- Attachment #1.1.3: Type: text/plain, Size: 73 bytes --]


Running Makefiles through the C preprocessor is evil.

-- 
Károly

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Double slashes in config.h
  2005-03-20  5:43 Double slashes in config.h Lőrentey Károly
@ 2005-03-20 18:01 ` Richard Stallman
  2005-03-20 18:30   ` David Kastrup
  2005-03-21 17:12   ` Lőrentey Károly
  0 siblings, 2 replies; 7+ messages in thread
From: Richard Stallman @ 2005-03-20 18:01 UTC (permalink / raw)
  Cc: emacs-devel

--ansi may have other consequences, and I don't trust it.
Can we avoid generating these double-slashes?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Double slashes in config.h
  2005-03-20 18:01 ` Richard Stallman
@ 2005-03-20 18:30   ` David Kastrup
  2005-03-21 17:08     ` Lőrentey Károly
  2005-03-21 17:30     ` Richard Stallman
  2005-03-21 17:12   ` Lőrentey Károly
  1 sibling, 2 replies; 7+ messages in thread
From: David Kastrup @ 2005-03-20 18:30 UTC (permalink / raw)
  Cc: Lőrentey Károly, emacs-devel

Richard Stallman <rms@gnu.org> writes:

> --ansi may have other consequences, and I don't trust it.
> Can we avoid generating these double-slashes?

I have had a bit of experience with this stuff in the installation
procedure of preview-latex and AUCTeX where several generated
directory names were passed through or into Lisp and caused trouble.

File name completion of directories in shells like bash adds the slash
automatically, so it is far too optimistic to assume that users won't
enter spurious slashes when specifying directory options.

One can clean up those names manually.  This is not necessarily
trivial, given that one would also want to remove trailing backslashes
on Windows.  And the experience was that there were almost always
oversights in that area whenever stuff got updated or rearranged.

And those are more or less minor packages and Makefiles.

So I'd say that it would be far too optimistic for a large project
like Emacs to rely on no double-slashes creeping up anywhere.

Yes, it can be done, but it is not something that works easily and can
be resolved without recurring time and again by accident.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Double slashes in config.h
  2005-03-20 18:30   ` David Kastrup
@ 2005-03-21 17:08     ` Lőrentey Károly
  2005-03-21 17:30     ` Richard Stallman
  1 sibling, 0 replies; 7+ messages in thread
From: Lőrentey Károly @ 2005-03-21 17:08 UTC (permalink / raw)
  Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 650 bytes --]

David Kastrup <dak@gnu.org> writes:
> Richard Stallman <rms@gnu.org> writes:
>> --ansi may have other consequences, and I don't trust it.
>> Can we avoid generating these double-slashes?
>
[...]
> Yes, it can be done, but it is not something that works easily and can
> be resolved without recurring time and again by accident.

As a quick & dirty hack, running config.h and both Makefile.c files
through a 's,//+,/,' filter would be easy, and AFAICS it would work
right at the moment.  On the other hand, it would surely ruin
someone's day later, when they want to put an actual `//' sequence in
there for some reason.

-- 
Károly

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Double slashes in config.h
  2005-03-20 18:01 ` Richard Stallman
  2005-03-20 18:30   ` David Kastrup
@ 2005-03-21 17:12   ` Lőrentey Károly
  2005-03-22  3:34     ` Richard Stallman
  1 sibling, 1 reply; 7+ messages in thread
From: Lőrentey Károly @ 2005-03-21 17:12 UTC (permalink / raw)
  Cc: emacs-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 208 bytes --]

Richard Stallman <rms@gnu.org> writes:
> --ansi may have other consequences, and I don't trust it.

-traditional also works, and is already used for a similar purpose in
configure.in.  How about this patch?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: Type: text/x-patch, Size: 545 bytes --]

--- orig/configure.in
+++ mod/configure.in
@@ -3126,6 +3126,14 @@
 	CPP_NEED_TRADITIONAL=no,
 	CPP_NEED_TRADITIONAL=yes)
 
+## New-fangled C preprocessors consider `//' to start a one-line comment.
+## The -ansi option forces GCC's cpp to ignore this syntax.
+
+AC_EGREP_CPP(yes//yes,
+	[yes//yes],
+	:,
+	CPP_NEED_TRADITIONAL=yes)
+
 AC_OUTPUT(Makefile lib-src/Makefile.c:lib-src/Makefile.in oldXMenu/Makefile \
 	man/Makefile lwlib/Makefile src/Makefile.c:src/Makefile.in \
 	lisp/Makefile lispref/Makefile lispintro/Makefile leim/Makefile, [

[-- Attachment #1.1.3: Type: text/plain, Size: 16 bytes --]


-- 
Károly

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Double slashes in config.h
  2005-03-20 18:30   ` David Kastrup
  2005-03-21 17:08     ` Lőrentey Károly
@ 2005-03-21 17:30     ` Richard Stallman
  1 sibling, 0 replies; 7+ messages in thread
From: Richard Stallman @ 2005-03-21 17:30 UTC (permalink / raw)
  Cc: Karoly.Lorentey, emacs-devel

I don't trust using --ansi for preprocessing of makefiles.
It has other effects and could easily cause trouble.

Is there no other way to turn off // in CPP?
How about CPP_NEED_TRADITIONAL=yes?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Double slashes in config.h
  2005-03-21 17:12   ` Lőrentey Károly
@ 2005-03-22  3:34     ` Richard Stallman
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Stallman @ 2005-03-22  3:34 UTC (permalink / raw)
  Cc: emacs-devel

    -traditional also works, and is already used for a similar purpose in
    configure.in.  How about this patch?

Thanks.  Would someone please install it?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-03-22  3:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-20  5:43 Double slashes in config.h Lőrentey Károly
2005-03-20 18:01 ` Richard Stallman
2005-03-20 18:30   ` David Kastrup
2005-03-21 17:08     ` Lőrentey Károly
2005-03-21 17:30     ` Richard Stallman
2005-03-21 17:12   ` Lőrentey Károly
2005-03-22  3:34     ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).