Re: #define sentinels with __FILE__

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

 



Hi,

On Mon, Dec 4, 2017 at 2:09 PM, Mathieu Malaterre
<mathieu.malaterre@xxxxxxxxx> wrote:
> Hi there,
>
> I've always assumed (before #pragma once), that sentinels were written like:
>
> https://en.wikipedia.org/wiki/Include_guard#Use_of_.23include_guards
>
> However grepping the linux source code I see:
>
> $ cat sound/soc/samsung/pcm.h
> #ifndef __S3C_PCM_H
> #define __S3C_PCM_H __FILE__
> <...>
> #endif /* __S3C_PCM_H */
>
> Why would any use:
>
> #define __S3C_PCM_H __FILE__
>
> instead of the simpler:
>
> #define __S3C_PCM_H
>
> This is not a copy/paste error, as I can find other references:
>
> $ grep -r "#define" * | grep "_H " | grep __FILE|wc
>      63     189    4996

Nevermind, I understood right after posting. This is to prevent
potential conflict in between multiple files being named the same and
multiple '__S3C_PCM_H' coming from actual different files.

In this case this looks like an error, but I can imagine some file
have identical names and thus potential conflicts for sentinels

Sorry for the noise,
-- 
Mathieu



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux