[GRASS-dev] __BEGIN_DECLS

In lib/vector/dglib/graph.h there is __BEGIN_DECLS (near top) and __END_DECLS (at bottom).

Are these needed?
What do they do?

John

In cdefs.h, they are defined like so:

/* C++ needs to know that types and declarations are C, not C++. */
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS
# define __END_DECLS
#endif

So standard C++ name de-mangling. Not needed, won't hurt.

So I broke 2 rules: I posted in HTML (oops, Windows default)
                    I wasted bandwidth on a question I really COULD find
on the web.

I'm sorry.
John
________________________________

  Subject: [GRASS-dev] __BEGIN_DECLS
  
  In lib/vector/dglib/graph.h there is __BEGIN_DECLS (near top)
and __END_DECLS (at bottom).

  Are these needed?
  What do they do?

  John

John Gillette wrote:

In lib/vector/dglib/graph.h there is __BEGIN_DECLS (near top) and
__END_DECLS (at bottom).

Are these needed?

No.

What do they do?

They are defined like so in type.h:

  #ifdef __cplusplus
  # define __BEGIN_DECLS extern "C" {
  # define __END_DECLS }
  #else
  # define __BEGIN_DECLS /* empty */
  # define __END_DECLS /* empty */
  #endif

Essentially, they allow the header to be used in C++ code. As the
rest of GRASS doesn't do this, there doesn't seem much point doing it
in a few specific headers.

--
Glynn Clements <glynn@gclements.plus.com>