public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/26052]  New: cpp does not honor the -undef option
@ 2006-01-31 22:09 peda at lysator dot liu dot se
  2006-01-31 22:11 ` [Bug preprocessor/26052] " peda at lysator dot liu dot se
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: peda at lysator dot liu dot se @ 2006-01-31 22:09 UTC (permalink / raw)
  To: gcc-bugs

I recently tried to build a package that was using cpp for other purposes than
preprocessing C files. Its configure script was looking for a way to not have
cpp predefine anything, and it specifically tried the -undef option, but
failed. From reading the docs, I couldn't figure out why. Here's a quote from
"info cpp":

'-undef'
     Do not predefine any system-specific or GCC-specific macros.  The
     standard predefined macros remain defined.  *Note Standard
     Predefined Macros::.

So I searched the web a bit and figured that I could probably fix it in the
specs file. I realise that the specs file probably isn't the canonical place to
change this.

I'll attach a patch for the specs file that wraps all old define rules for cpp
inside the following:

%{!undef:old define rules}

I don't know if this is the correct thing to do, but it works for me<TM>.

"cpp -undef -mD < /dev/null" gives me this list:

#define __unix 1
#define __STDC_HOSTED__ 1
#define __unix__ 1
#define unix 1
#define __CYGWIN__ 1
#define __CYGWIN32__ 1

All but __STDC_HOSTED__ are system/gcc-specific according to "*Note Standard
Predefined Macros".

In my specific case, the configure script is looking for a way to not have
"unix" defined.

FWIW, the provided patch fixes all of the above, so that the output from the
above command is:

#define __STDC_HOSTED__ 1

Cheers,
Peter


-- 
           Summary: cpp does not honor the -undef option
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: peda at lysator dot liu dot se
  GCC host triplet: i686-pc-cygwin


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26052


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

* [Bug preprocessor/26052] cpp does not honor the -undef option
  2006-01-31 22:09 [Bug preprocessor/26052] New: cpp does not honor the -undef option peda at lysator dot liu dot se
@ 2006-01-31 22:11 ` peda at lysator dot liu dot se
  2006-01-31 22:13 ` [Bug target/26052] " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: peda at lysator dot liu dot se @ 2006-01-31 22:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from peda at lysator dot liu dot se  2006-01-31 22:11 -------
Created an attachment (id=10768)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10768&action=view)
Fixup -undef option in specs file.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26052


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

* [Bug target/26052] cpp does not honor the -undef option
  2006-01-31 22:09 [Bug preprocessor/26052] New: cpp does not honor the -undef option peda at lysator dot liu dot se
  2006-01-31 22:11 ` [Bug preprocessor/26052] " peda at lysator dot liu dot se
@ 2006-01-31 22:13 ` pinskia at gcc dot gnu dot org
  2006-01-31 22:15 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-31 22:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-01-31 22:13 -------
This is a target specific issue.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|preprocessor                |target
   GCC host triplet|i686-pc-cygwin              |
 GCC target triplet|                            |i686-pc-cygwin


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26052


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

* [Bug target/26052] cpp does not honor the -undef option
  2006-01-31 22:09 [Bug preprocessor/26052] New: cpp does not honor the -undef option peda at lysator dot liu dot se
  2006-01-31 22:11 ` [Bug preprocessor/26052] " peda at lysator dot liu dot se
  2006-01-31 22:13 ` [Bug target/26052] " pinskia at gcc dot gnu dot org
@ 2006-01-31 22:15 ` pinskia at gcc dot gnu dot org
  2006-02-02 16:09 ` [Bug target/26052] cygwin's defnes " gerrit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-31 22:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-01-31 22:15 -------
The bug is in the SPECs but it is generated from
gcc/config/i386/cygwin.h:
#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
  %{mno-win32:%{mno-cygwin: %emno-cygwin and mno-win32 are not compatible}} \
  %{mno-cygwin:-D__MSVCRT__ -D__MINGW32__ %{!ansi:%{mthreads:-D_MT}}}\
  %{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix} -D__unix__ -D__unix
}\
  %{mwin32|mno-cygwin:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!ansi:-DWINNT}}\
  %{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s -idirafter
../../include/w32api%s}}\
"


Really there should be a better way of doing this instead of using a SPECs.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-01-31 22:15:09
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26052


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

* [Bug target/26052] cygwin's defnes does not honor the -undef option
  2006-01-31 22:09 [Bug preprocessor/26052] New: cpp does not honor the -undef option peda at lysator dot liu dot se
                   ` (2 preceding siblings ...)
  2006-01-31 22:15 ` pinskia at gcc dot gnu dot org
@ 2006-02-02 16:09 ` gerrit at gcc dot gnu dot org
  2006-02-02 16:39 ` pinskia at gcc dot gnu dot org
  2006-02-02 16:42 ` [Bug target/26052] cygwin's defnes does not honor the -undef option and -std=c89 is not the same as -ansi pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: gerrit at gcc dot gnu dot org @ 2006-02-02 16:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from gerrit at gcc dot gnu dot org  2006-02-02 16:09 -------
IMO it should be coded in the executable itself that -undef skips reading the
specs at all.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26052


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

* [Bug target/26052] cygwin's defnes does not honor the -undef option
  2006-01-31 22:09 [Bug preprocessor/26052] New: cpp does not honor the -undef option peda at lysator dot liu dot se
                   ` (3 preceding siblings ...)
  2006-02-02 16:09 ` [Bug target/26052] cygwin's defnes " gerrit at gcc dot gnu dot org
@ 2006-02-02 16:39 ` pinskia at gcc dot gnu dot org
  2006-02-02 16:42 ` [Bug target/26052] cygwin's defnes does not honor the -undef option and -std=c89 is not the same as -ansi pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-02 16:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-02-02 16:39 -------
(In reply to comment #4)
> IMO it should be coded in the executable itself that -undef skips reading the
> specs at all.

No, that would not work as this SPECs is used for other things too.
The correct way to fix this is to move the specs handling of defines to
TARGET_OS_CPP_BUILTINS.
That will also fix the problems referenced in PR 545.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26052


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

* [Bug target/26052] cygwin's defnes does not honor the -undef option and -std=c89 is not the same as -ansi
  2006-01-31 22:09 [Bug preprocessor/26052] New: cpp does not honor the -undef option peda at lysator dot liu dot se
                   ` (4 preceding siblings ...)
  2006-02-02 16:39 ` pinskia at gcc dot gnu dot org
@ 2006-02-02 16:42 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-02 16:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-02-02 16:42 -------
(In reply to comment #5)
> (In reply to comment #4)
> No, that would not work as this SPECs is used for other things too.
> The correct way to fix this is to move the specs handling of defines to
> TARGET_OS_CPP_BUILTINS.

For cygwin.h, the correct macro is EXTRA_OS_CPP_BUILTINS as
TARGET_OS_CPP_BUILTINS is used in cygming.h already and just calls
EXTRA_OS_CPP_BUILTINS for the cygwin specific defines.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26052


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

end of thread, other threads:[~2006-02-02 16:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-31 22:09 [Bug preprocessor/26052] New: cpp does not honor the -undef option peda at lysator dot liu dot se
2006-01-31 22:11 ` [Bug preprocessor/26052] " peda at lysator dot liu dot se
2006-01-31 22:13 ` [Bug target/26052] " pinskia at gcc dot gnu dot org
2006-01-31 22:15 ` pinskia at gcc dot gnu dot org
2006-02-02 16:09 ` [Bug target/26052] cygwin's defnes " gerrit at gcc dot gnu dot org
2006-02-02 16:39 ` pinskia at gcc dot gnu dot org
2006-02-02 16:42 ` [Bug target/26052] cygwin's defnes does not honor the -undef option and -std=c89 is not the same as -ansi pinskia at gcc dot gnu dot org

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).