As far as I remember (...) pragma acts on a 'module'. "Handle this module only once."
For most cases, this indeed means a (disk- or memory-based) file. Pragma's typically
handle only that module, and any modules it includes (#include) or otherwise references.
So,
foo.c
#pragma once
means "handle this module once", which translates to the entire module and what it
includes. foo.c, but also anything it includes - the preprocessor typically stops parsing
the file after it detects it already did before.
> Can i pragma once in the middle of my header
file?
Yes, but typically, its at the top.
> Can I pragma once conditionally?
That is a good question, dunno. Sounds a bit weird, but hmmm.
> On linux we can use inode as a
proxy, but win32 is lacking inodes… that’s the current
> problem
to solve
Windows (well, NTFS) uses file object IDs; either through the MFT or through the API.
Like inodes, they are a per-volume ID (local to the filesystem, so a file module is ID'ed
by (volume ID + file ID.)
For Windows, we can use the
FileReference
The 8-byte file reference number for the file. NTFS generates this
number and assigns it to the file
automatically when the file is
created.
info, for example.
Retrieving this takes time, but probably less so than doing a full hash on its contents.