tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Definitions of types also as macros



On Tue 06 Nov 2018 at 23:19:08 +0300, Valery Ushakov wrote:
> Also your change breaks redefining intN_t types with the preprocessor.
> E.g.
> 
>     #define uint32_t unsigned long long
>     #include <stdint.h>
> 
> is now broken with your change.

But should that really be allowed? I haven't got the Standard at hand
but I strongly suspect that uint32_t is officially in the namespace of
<stdint.h> and therefore, if you #include it, you as a user shouldn't
mess with uint32_t (or risk nasal daemons).

Maybe an implementation something like this could work:

#ifndef uint32_t
typedef __uint32_t      uint32_t;
#define uint32_t        uint32_t
#endif

Recursive macro definitions are not supposed to be re-expanded, so this
would work as a guard but still leave uint32_t in source code unchanged.

> -uwe
-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- "What good is a Ring of Power
\X/ rhialto/at/falu.nl      -- if you're unable...to Speak." - Agent Elrond

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index