Open
Bug 836923
Opened 11 years ago
Updated 2 years ago
Many of the NS_* nsresult constants don't work in C
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
NEW
People
(Reporter: Waldo, Unassigned)
Details
In C the various constants like NS_OK and such are created by #defines. Some of them are purely created from numeric constants. Others look like this: #define NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ((nsresult)(FAILURE(7))) But it so happens that FAILURE is #define'd just before the list of error #defines, then #undef'd right after. This is fine for all the non-C cases that put the error values into enum initializers or global consts, thereby using the definition of FAILURE at that point. But the C case won't be, because use of NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR and so on will expand FAILURE based on its definition *at that point*. So using this in a C file is going to have it expand into a call to a non-existent FAILURE function, and things will crash and burn. There are two possible fixes here: make the C #defines work (not easy, given how the list of C #defines is generated), or switch all our C code that needs nsresult to C++. I'd argue for the latter (there really isn't much) so we have fewer language quirks to think about, but then again I hope never to touch this again, so it's not *my* time that would be wasted making C work. :-)
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•