[mercury-users] mercury_trace_external.c:164: bad attribute specification, expecting constant, found `('

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Apr 9 13:45:58 AEST 2001


On 29-Apr-2001, Terrence Brannon <princepawn at earthlink.net> wrote:
> After changing Word to MR_Word in mercury_trace.c, I then encountered
> the following warnings, but compilation continued... Mac OS X iBook is
> the platform.

> mercury_trace_external.c:164: bad attribute specification, expecting constant, found `('
> mercury_trace_external.c:164: syntax error, found `1'
> mercury_trace_external.c:164: syntax error, found `,'
> mercury_trace_external.c:164: illegal function definition, found `)'
> cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode

Hmm, interesting.  Apple have added support for precompiled headers to
their version of GCC.  Apparently their precompiled header version of the
preprocessor doesn't understand exactly the same syntax for __attribute__
as GCC's standard preprocessor; this leads to the syntax errors above,
but it then retries using the standard preprocessor, which succeeds,
which is why the apparent errors don't stop compilation.

This is a bug in Apple's version of gcc, and ideally it ought to be
reported to them.  It would probably not be hard to construct a small test
cases that showed the problem.

In the mean time, I have a couple of possible work-arounds:
(1) The easy approach: just ignore it.  It's only a warning.
(2) From the error message, it looks like the following patch might
    perhaps avoid the warning.

Index: mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.55
diff -u -d -u -r1.55 mercury_trace_external.c
--- mercury_trace_external.c	2001/03/18 23:10:16	1.55
+++ mercury_trace_external.c	2001/04/09 03:41:28
@@ -156,7 +156,7 @@
 */
 #ifdef __GNUC__
   #define MR_LIKE_PRINTF(format_argnum, vars_argnum) \
-    __attribute__ ((format (printf, (format_argnum), (vars_argnum))))
+    __attribute__ ((format (printf, format_argnum, vars_argnum)))
 #else
   #define MR_LIKE_PRINTF(n, m) /* nothing */
 #endif

(3) The following patch will almost certainly make the warnings go away.
    However, it's probably not a good idea since it reduces the amount
    of static checking that GCC will do.

Index: mercury_trace_external.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_external.c,v
retrieving revision 1.55
diff -u -d -u -r1.55 mercury_trace_external.c
--- mercury_trace_external.c	2001/03/18 23:10:16	1.55
+++ mercury_trace_external.c	2001/04/09 03:33:22
@@ -153,8 +153,10 @@
 ** for printf-style functions. 
 ** (See the "Function attributes" section of "C extensions"
 ** chapter of the GNU C manual for detailed documentation.)
+**
+** XXX Disabled since it causes spurious warnings on Darwin (MacOS X).
 */
-#ifdef __GNUC__
+#if 0 /* ifdef __GNUC__ */
   #define MR_LIKE_PRINTF(format_argnum, vars_argnum) \
     __attribute__ ((format (printf, (format_argnum), (vars_argnum))))
 #else

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list