Re: [dev] [general][discussion] constants: `#define` or `static const`

From: Anselm Garbe <>
Date: Sat, 14 Oct 2017 09:26:55 +0200

Hi Matthew,

On 12 October 2017 at 16:21, Matthew Parnell <> wrote:
> I'm writing a header file that will contain constants required.
> Should I use:
> #define FOO 123.456

Depends on the kind of header file you are talking about. A CPP define
can be the right thing, if this header file is part of some API used
by many programs and you don't want to impose variable or constants
into those programs.

If the header is only included by your program (like config.h in
suckless tools) then using proper variable or constant declaration
might be the better approach.

But I wouldn't demonise the definition of constant values using CPP.
CPP starts becoming evil, if you incorporate excessive macro variable
expansion that makes it hard being tracked down in case of compile
errors. Simple #define's have never been a problem when analysing
compile errors.

Received on Sat Oct 14 2017 - 09:26:55 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 14 2017 - 09:36:15 CEST