Date: Tue, 27 Aug 2024 18:47:20 +0200
So the proposed #pragma once would only care for file contents, not for path or filename?
I.e. a.h could prevent b.h from being included? Or patha/a.h couild prevent pathb/b.h?
That could lead to interdependencies between different libraries.
There are some preprocessor tricks, where you define macros and then include files, which use the defined macros.
Some of the include files could accidentally (e.g. taken from the same original source) be the same between different projects.
E.g. (simple example)
------------- patha/definealla.h and pathb/defineallb.h -------------
#pragma once
#define basename A
#include "usebasename.h"
#undef basename
#define basename B
#include "usebasename.h"
#undef basename
---------------------------------------------------------------------------------------
patha/usebasename.h and pathb/usebasename.h would be different depending on the needs of libarary a and library b.
But as patha/definealla.h and pathb/defineallb.h are the same and both use #pragma once, the latter would not be included, although they have differents paths and different names!
-----Ursprüngliche Nachricht-----
Von:Jeremy Rifkin via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Di 27.08.2024 18:36
Betreff:Re: [std-proposals] Revising #pragma once
An:Gašper Ažman <gasper.azman_at_[hidden]>;
CC:Jeremy Rifkin <rifkin.jer_at_[hidden]>; std-proposals_at_[hidden];
This paper proposes #pragma once mean don’t #include the same contents again. Unlike GCC which will perform multiple inclusion if mtime differs. This paper leaves open the possibility of implementations doing their own fast path checks of inode, stat, etc., but ultimately the file contents are what matter.
Jeremy
Received on 2024-08-27 16:47:22