[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cpp use in cc-mode is broken

From: Nick Roberts
Subject: cpp use in cc-mode is broken
Date: Sat, 30 Apr 2005 09:50:26 +1200

 > As of a few days ago, the cc-mode in cvs emacs seems to preprocess the
 > source file in order to determine the C macros present.
 > There are two things wrong with this:
 > 1) it uses /lib/cpp unconditionally, but the use of the -dM switch
 > suggests it currently requires gcc (at least, /lib/cpp on neither AIX
 > nor HP/UX support that switch).  So this should either be
 > user-configurable, or defaulted to "gcc -E".

I was hoping that the maintainers of cc-mode would see this and fix it.
It needs to be generalised like c-macro-preprocessor in cmacexp.el and
probably combined with it. Making it unconditional means that fixes
might be applied more quickly.

Editing c-macro-preprocessor, are you saying this would work?:

(defcustom c-preprocessor-command
  ;; Cannot rely on standard directory on MS-DOS to find CPP.  In
  ;; fact, cannot rely on having cpp.exe, either, in latest GCC
  ;; versions.
  (cond ((eq system-type 'ms-dos) "gcc -E -o - -")
        ;; Solaris has it in an unusual place.
        ((and (string-match "^[^-]*-[^-]*-\\(solaris\\|sunos5\\)"
              (file-exists-p "/opt/SUNWspro/SC3.0.1/bin/acomp"))
         "/opt/SUNWspro/SC3.0.1/bin/acomp -E")
        ((file-exists-p "/usr/ccs/lib/cpp") "/usr/ccs/lib/cpp")
        (t "/lib/cpp"))
  "The preprocessor used by the c-mode package.

 > 2) it does this even for files that don't exist (e.g. when you open a
 > fresh file); for such cases, either cpp should simply not be run, or a
 > temp file should be used (containing the buffer contents).

Well it sets cc-define-alist to nil for a new file which doesn't seem
wrong. However, it should regenerate cc-define-alist after the file has
been edited. Perhaps that can be done with a hook.

 > The patches below resolve the immediate problem, just not optimally.

For some reason Sam Steingold has applied his own similar patch but without
the cond clause. Lets try to find something more general so that most
users don't have to customize c-preprocessor-command.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]