Cannot compile with Visual C++ when exception is disabled and _HAS_EXCEPTIONS is set to 0
Description
Attachments
relates to
Activity
UnicodeBot June 30, 2018 at 11:45 PM
Trac Comment 12 by —2012-06-29T00:10:18.970Z
was filed as a follow-up to this ticket.
UnicodeBot June 30, 2018 at 11:45 PM
Trac Comment 11 by —2012-06-28T23:30:40.540Z
I've landed a patch and am going to file a new ticket to deal with 4275 warning. Unless exeption is disabled, it's not an issue. And those who disable exception can suppress 4275 warning 'globally' for ICU.
Using pragma to supporess 4275 '''locally''' does not work.
UnicodeBot June 30, 2018 at 11:45 PM
Trac Comment 10 by —2012-06-21T20:13:13.965Z
rtti.patch attached does not work any more with Visual Stuidio 10. It spits the following warning:
Mozilla stumble upon a similar issue and they're considering turning off C4275 warning globally.
UnicodeBot June 30, 2018 at 11:45 PM
Trac Comment 8 by —2012-02-24T19:06:16.796Z
Missed the 49 boat. I'll check this into a branch (either mine or googlers/49branch) and see if it can be merged to a maintenance release (or 50).
UnicodeBot June 30, 2018 at 11:45 PM
Trac Comment 7 by —2012-02-23T23:38:14.199Z
Sorry again for the late reply. <typeinfo> has to be included after this:
Otherwise, MSVC is not happy at all. So, putting the above in pwin32.h (now platform.h) or putilimpl.h would not work unless we include <typeinfo> after either of that is included.
Given this, I'll go ahead with utypeinfo.h in common and replacing <typeinfo> with "utypeinfo.h".
Whenever typeid is used, <typeinfo> is included.
In Visual C++, the declaration of bad_cast in <typeinfo> looks like the following:
where _STD_BEGIN is 'namespace std {' and _STD_END is '}'
ICU cannot be compiled if _HAS_EXCEPTIONS is set to 0 (which is what Chrome does) because 'exception' is not defined in std namespace in VC++ headers (VC++ throws this error : C2504: 'exception' : base class undefined).
One work around is for the customer of ICU (e.g. Chrome) to set _HAS_EXCEPTIONS to 1 for ICU while still disabling exception handling. VC++ complaines (emits warning) : "C++ exception handler used, but unwind semantics are not enabled. Specify /EHs"
Perhaps, this is ok.
An alternative needs an ugly change in the ICU source. Whenever <typeinfo> is included, the following has to be done:
30+ files have to be changed as shown above. VC++ does not complain any more with the above. And the size of icuuc.lib is 1kB smaller and icui18n.lib is 5kB smaller. I haven't measured the size difference of dll files.
The patch is available at http://codereview.chromium.org/6484008/ (patch set 5).
Would this 'pollution' be acceptable? It may be useful to projects/ICU customers other than Chrome/Chromium.
If acceptable, I'll make a patch and apply to the trunk.