[Webkit-unassigned] [Bug 65401] New: Weird macros for use in "#if" in Platform.h
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Jul 29 17:06:03 PDT 2011
https://bugs.webkit.org/show_bug.cgi?id=65401
Summary: Weird macros for use in "#if" in Platform.h
Product: WebKit
Version: 528+ (Nightly build)
Platform: Unspecified
OS/Version: Unspecified
Status: UNCONFIRMED
Severity: Normal
Priority: P2
Component: Platform
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: schaub.johannes at googlemail.com
Source/JavaScriptCore/wtf/Platform.h contains macros like this one:
#define PLATFORM(WTF_FEATURE) (defined WTF_PLATFORM_##WTF_FEATURE && WTF_PLATFORM_##WTF_FEATURE)
and their use is for code as follows
#if PLATFORM(MAC) || (PLATFORM(QT) && USE(QTKIT))
#include "MediaPlayerPrivateQTKit.h"
#if USE(AVFOUNDATION)
#include "MediaPlayerPrivateAVFoundationObjC.h"
#endif
There are two things that make me thing that the first part of that logical-AND in the definition of "PLATFORM" isn't needed and may actually be harmful.
1. Why is it harmful? The C++ spec says at 16.1p4 "If the token 'defined' is generated as a result of this replacement process ..., the behavior is undefined.". That's what's happening here.
2. Why is it not needed? Because "#if" replaces any unknown macros by "0". And the macro already relies on this to happen. If it wouldn't happen, the "&& WTF_PLATFORM_##WTF_FEATURE" would be broken if the macro doesn't exist.
I don't know why that code is chosen to be that way, but I recommend to change it to the following, if it works on all targets:
#define PLATFORM(WTF_FEATURE) (WTF_PLATFORM_##WTF_FEATURE)
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list