Why do I see THROW in a C library?

This header is likely shared between the C and C++ compiler for that vendor. Did you look what __THROW is defined as?

I suspect something akin to:

#ifdef __cplusplus
    #define __THROW throw()
#else
    #define __THROW
#endif

Or for actual specifications:

#ifdef __cplusplus
    #define __THROW(x) throw(x)
#else
    #define __THROW(x)
#endif

As you can see, in a C build, it expands to nothing. In C++, it does what you expect. This allows vendors to reuse the same file.


Just to nitpick, this isn’t entirely true: “(which is only a C library – nothing to do with C++)”

The C++ standard library includes the ability to use the C standard library. The actual header is <cxxx> where xxx is the C header name. That is, to include the C header <stdlib.h> in C++, you do <cstdlib>. So it does have to do with C++. 🙂

This is why you see the code you do. Duplicating the header for two different languages would be a nightmare for maintenance and cleanliness.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)