printf/fprintf unconditionally defined as macros

RESOLVED FIXED

Status

()

Core
XPCOM
RESOLVED FIXED
18 years ago
17 years ago

People

(Reporter: Ulrich Drepper, Assigned: Scott Collins)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

18 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux 2.4.0-prerelease i686; en-US; m18)
Gecko/20010202
BuildID:    20020203

In the file xpcom/base/nslog.h macros of the names printf and fprintf
are unconditionally defined.  This cannot be done after including
<stdio.h> without preparation since the system headers can define
macros with these names, too.  This is the case with recent glibc
versions.

Reproducible: Always
Steps to Reproduce:
Compile mozilla on a system with a recent glibc (>= 2.2.1).

Actual Results:  The compiler emits a warning about printf being redefined.

Expected Results:  No warning.
(Reporter)

Comment 1

18 years ago
Created attachment 24348 [details] [diff] [review]
This patch fixes the problem.
(Reporter)

Comment 2

17 years ago
Hello, anybody home???  Would somebody please apply the simple patch I
submitted?  The code as is is wrong (read the C standard) and the patch is
definitely not hurting anybody.
(Assignee)

Comment 3

17 years ago
Sorry I've been so innattentive.  I'll take a look at this patch and your
|strtok| patch within the next couple of days.
Status: NEW → ASSIGNED
(Assignee)

Comment 4

17 years ago
Your patch looks good to both me and jst but we have one question: is an
unconditional |#undef| valid?  Or should we be wrapping the |#undef| in a |#ifdef|?
(Reporter)

Comment 5

17 years ago
Unconditional #undef are OK.  There is no requirement in ISO C that the macro
has to be defined before it can be undefined.

ISO C99, 6.10.3.5

A preprocessing directive of the form

  # undef identifier new-line

causes the specified identifier no longer to be defined as a macro name. It is
ignored if the specified identifier is not currently defined as a macro name.
(Assignee)

Comment 6

17 years ago
Cool :-)  OK, I'll check this in at my earliest opportunity (==green, open tree).
(Assignee)

Comment 7

17 years ago
fix checked in to version 1.5 of "nslog.h"
Status: ASSIGNED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.