|
|
|
|
|
by loeg
2765 days ago
|
|
> You could say that there's no reason we're still using a stupid preprocessor hack of textual inclusion to import interfaces. You could say that. I didn't. Bolting on some sort of module system is just a totally different scope of enhancement than my modest proposal. > As usual, the devil lies in the detail. If you want to make pragma once robust you need to checksum files, which in the end will be slower than include guards. That's just not true. It doesn't need to be robust against byzantine source trees and/or build systems to be defined in the C standard or to be useful. The standard can leave the concept of "the same file" implementation-defined, as it does many other concepts. On Unix system C implementations, it is sufficient to use stat() and compare st_ino and st_dev against previously observed values for a given compilation unit. You do not need to checksum files. You especially do not need to write the specific behavior of checksumming header files into the C standard. |
|
A locally developed hack, or even a compiler extension, doesn't have to be; an ISO-standard feature should be well specified.
If something is specified in such a way that it is less robust than the #ifndef trick, then any programmer worth their salt will use the #ifndef trick.
An acceptable pragma-once would look like this:
Basically it should take an argument string which specifies an ID for the file, intended to be unique.