[Top][All Lists]

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

Re: insert-header-preprocessor-definition

From: Yuri Khan
Subject: Re: insert-header-preprocessor-definition
Date: Sun, 15 Apr 2018 14:44:47 +0700

On Sun, Apr 15, 2018 at 8:02 AM, Ben Bacarisse <address@hidden> wrote:

> The C standard lists, for every header, any patterns of macro names that
> are reserved to the implementation.  errno.h, for example, reserves all
> macro names that start E followed by a digit or another upper case
> latter.  Thus a program that uses ERROR_H whilst also including errno.h
> is technically undefined even if errno.h does not actually use that
> macro name.

The issue is not limited to standard headers. As long as you start
using libraries, you are going to include their headers. Woe unto you
if you clash with any macros they define, or with any of their header
include guards, past, current or future.

The practical solution is, of course, the same as with all name
conflict issues: Namespacing. That is, in your project, you start all
preprocessor defines with the name of your project. And if the project
name is not unique enough, then also with your own name or the name of
your company.

On the other hand, the two or three compilers out there
that are most likely to be used to compile your project
already support #pragma once.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]