Closed Bug 1242060 Opened 9 years ago Closed 9 years ago

Use #pragma once header guards in SpiderMonkey

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox46 --- affected

People

(Reporter: terrence, Assigned: terrence)

References

(Depends on 1 open bug)

Details

Attachments

(1 file)

The internet says that #pragma once has been safe to use basically forever in every compiler that I've even heard of. So let's try it out. Stuff builds locally, let's see what try has to say: https://treeherder.mozilla.org/#/jobs?repo=try&revision=986d05d5eb77 You may not want to review every single line; turns out we have lots of headers. Like, way more headers than I would have thought possible: 436 files changed, 437 insertions(+), 1746 deletions(-) The script I used to make the change is: '''bash #!/bin/bash FILES=`find . -name "*.h" | grep -v irreg | grep -v libffi | grep -v vixl | grep -v editline | grep -v vtune | grep -v style | grep -v llvm-compiler-rt | grep -v js-conf` for FILE in $FILES; do GUARDNAME=`sed -n "s/#ifndef \(.*_h\)$/\1/p" ${FILE}` if [ -z $GUARDNAME ]; then exit 1 fi grep -q "#endif....${GUARDNAME}" ${FILE} || exit 2 sed -i "s/#ifndef ${GUARDNAME}$/#pragma once/" ${FILE} sed -i "/#define ${GUARDNAME}/d" ${FILE} sed -i "/#endif....${GUARDNAME}/d" ${FILE} sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' ${FILE} done ''' One edit was required in CommonPropertyNames.h: g++ did not like EOF terminating the macro after I stripped the trailing whitespace.
There was a proposal to do this for Gecko back in 2012: https://groups.google.com/forum/#!topic/mozilla.dev.platform/PgDjWw3xp8k I'm not sure if the objections there still apply or not, but it is at least worth reading over.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
Component: JavaScript: GC → JavaScript Engine
(In reply to Mike Hommey [:glandium] from comment #2) > This comment still applies. > https://groups.google.com/d/msg/mozilla.dev.platform/PgDjWw3xp8k/PLYQc5xoWmsJ Well, drat!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: