From 8466c6d4d39ac880edc6c44e60585517c20e4068 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 3 Jun 2009 21:02:16 +0000 Subject: merge from gcc --- include/ChangeLog | 4 ++++ include/ansidecl.h | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/ChangeLog b/include/ChangeLog index 93308e8..1af04e8 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2009-06-02 Ian Lance Taylor + + * ansidecl.h (EXPORTED_CONST): Define. + 2009-05-31 Ian Lance Taylor * ansidecl.h: Add extern "C" when compiling with C++. Treat C++ diff --git a/include/ansidecl.h b/include/ansidecl.h index c83b8c0..f9864cd 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -395,6 +395,18 @@ So instead we use the macro below and test it against specific values. */ #define __extension__ #endif +/* This is used to declare a const variable which should be visible + outside of the current compilation unit. Use it as + EXPORTED_CONST int i = 1; + This is because the semantics of const are different in C and C++. + "extern const" is permitted in C but it looks strange, and gcc + warns about it when -Wc++-compat is not used. */ +#ifdef __cplusplus +#define EXPORTED_CONST extern const +#else +#define EXPORTED_CONST const +#endif + #ifdef __cplusplus } #endif -- cgit v1.1