Closed Bug 1652914 (C11_static_assert) Opened 4 years ago Closed 4 years ago

Replace MOZ_STATIC_ASSERT with static_assert in C code (and remove MOZ_STATIC_ASSERT)

Categories

(Core :: MFBT, task, P3)

task

Tracking

()

RESOLVED FIXED
81 Branch
Tracking Status
firefox-esr68 --- wontfix
firefox-esr78 --- wontfix
firefox78 --- wontfix
firefox79 --- wontfix
firefox80 --- wontfix
firefox81 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

Details

Attachments

(2 files)

MOZ_STATIC_ASSERT is currently used only in C code, specifically in the libmar library:

https://searchfox.org/mozilla-central/rev/fa2df28a49883612bd7af4dacd80cdfedcccd2f6/modules/libmar/src/mar.h#27

https://searchfox.org/mozilla-central/rev/fa2df28a49883612bd7af4dacd80cdfedcccd2f6/modules/libmar/src/mar_private.h#30-31,35-37

static_assert is available in both C++11 and C11. While C++11's static_assert is a keyword, C11's static_assert is a macro defined in assert.h (that expands to the C11 keywoard _Static_assert). libar's header files are included in both C and C++ code, so we must #include assert.h to use static_assert.

https://en.cppreference.com/w/c/language/_Static_assert
https://en.cppreference.com/w/cpp/language/static_assert

static_assert is available in both C++11 and C11. While C++11's static_assert is a keyword, C11's static_assert is a macro defined in assert.h (that expands to the C11 keywoard _Static_assert). libar's header files are included in both C and C++ code, so we must #include assert.h to use static_assert.

https://en.cppreference.com/w/c/language/_Static_assert

Replacing MOZ_STATIC_ASSERT with C11's static_assert requires compiling our C code as C11 instead of C99 (bug 1653182).

Green Try build:

https://treeherder.mozilla.org/#/jobs?repo=try&revision=bbb5b1d93d652d655d0e95691d23dc9aebf35581

Depends on: 1653182
Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/14853017df35 Part 1: Replace MOZ_STATIC_ASSERT with static_assert in C code. r=jwalden https://hg.mozilla.org/integration/autoland/rev/73c606e0647d Part 2: Remove unused MOZ_STATIC_ASSERT macro. r=jwalden
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: