[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GMP C/C++ namespace conflict
From: |
Hans Aberg |
Subject: |
Re: GMP C/C++ namespace conflict |
Date: |
Thu, 3 May 2001 11:22:19 +0200 |
At 09:51 +1000 2001/05/03, Kevin Ryde wrote:
>> >#ifdef __cplusplus
>> >#include <cstddef>
>> >#else
>> >#include <stddef.h>
>> >#endif
>
>Yep, thanks, that would be fine. But is there a c++ standards version
>that can be checked in the preprocessor to see whether the <cstddef>
>ought to work?
C++ only provides the __cplusplus macro. But I do not think that is a
problem anymore, because the standard is from 1998 (ANSI
ISO+IEC+14882-1998), so most if not all C++ compilers should comply these
days.
>> Oops. If one is doing it, size_t will be named std::size_t. So one might add
>> #ifdef __cplusplus
>> #define size_t std::size_t
>> #endif
>
>Really? Isn't it the purpose of <cstddef> to provide a plain size_t
>(or do I misunderstand badly)?
The C++ standard explicitly states (17.4.1.2:4) that C names like size_t
should end up in the namespace std; the effect of using a C compatibility
header is the same, except with a "using namespace std" added (D.5:2).
So my compiler is right, and one has to tweak the code something like I
suggested.
Hans Aberg