Closed Bug 67600 Opened 24 years ago Closed 23 years ago

printf/fprintf unconditionally defined as macros

Categories

(Core :: XPCOM, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: drepper, Assigned: scc)

References

()

Details

Attachments

(1 file)

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.
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.
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
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|?
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.
Cool :-)  OK, I'll check this in at my earliest opportunity (==green, open tree).
fix checked in to version 1.5 of "nslog.h"
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: