[PATCH] Hspell plugin for KSpell2

Michael Pyne pynm0001 at comcast.net
Mon May 2 07:29:54 BST 2005


On Sunday 01 May 2005 08:08 am, Dan Kenigsberg wrote:
> However, there is a problem with having #ifdef __cplusplus in the header
> file, as it might be used by a non-g++ compiler that might not have this
> macro. I am not sure that this is the Right Way to do it in pure C
> libraries, even though it is routinely done by others.

The #ifdef construct is supported by every C *and* C++ compiler out there.

__cplusplus is defined by *every* standard-compliant C++ compiler out there, 
including Watcom, Microsoft, Borland, Symantec, Sun, and GNU's.

The reason every library does it (including libraries like glib) is because 
it's safe and standard to do so.

For instance, consider the following glib source code (glib/gmacros.h)

/* Guard C code in headers, while including them from C++ */
#ifdef  __cplusplus
# define G_BEGIN_DECLS  extern "C" {
# define G_END_DECLS    }
#else
# define G_BEGIN_DECLS
# define G_END_DECLS
#endif

glib is used on the various UNIX-like platforms, and Windows as well.  Maybe 
even Mac OS X.  And they use the #ifdef __cplusplus guard because it WORKS 
EVERYWHERE, including plain ol' C compilers.

So, thanks for all of your work on the plugin, I'm just trying to put your 
mind as ease about the __cplusplus macro thing, it is not a g++ extension, 
it's standard C++ that will not affect C compilers.

Regards,
 - Michael Pyne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050502/8219a7e8/attachment.sig>


More information about the kde-core-devel mailing list