tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Relative paths of include files are not normalised, w


From: draco
Subject: Re: [Tinycc-devel] Relative paths of include files are not normalised, which can break #pragma once
Date: Wed, 28 Jun 2023 21:28:58 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Pragma once is implementation defined, so I ponder a bit on the definition…

  1. pragma once is defined on the file level, while regular source code can be amalgamated to a single source and in fact this is what the preprocessor does
  2. does pragma once exclude the whole file from re-inclusion? And if so, is this true for wherever the pragma in the file is set? Can i pragma once in the middle of my header file?  Can I pragma once conditionally? What would be the consequences?
  3. does pragma once therefor refer to a certain file? Or to the file content? What is a certain file? This is defined by the filesystem... On a harddisk, it means the physically same blocks on the drive, but what does it mean for different types off FS, lets say memory based? On linux we can use inode as a proxy, but win32 is lacking inodes… that’s the current problem to solve
  4. So, how can any compiler safely assure a files identity? Is there any failsafe solution for the pragma once dilemma out there?

Moreover, do we really have projects, where headerA.h is symlinked to headerB.h (different filenames) and do we expect pragma once to exclude headerB? Is this sane behavior? What usecases are implied here?

Or can we safely assume, that two files with the same name, size and mtime are identical, even on windows?

So, the actual solution is good for linux (use dev/inode from stat) but not for win32, where every file is read and hashed. On the other hand, win32 does not use symlinks for files to myknowledge.

Thiago proposes a normalized path based solution. I would say, even easier, two files with the same tailname, size and mtime can be assumed to be identical in this context.

Michael




reply via email to

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