C++ Logo

std-proposals

Advanced search

Re: [std-proposals] #pragma once safer alternative

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Sun, 23 Mar 2025 13:03:35 +0100
Again the same question as Thiago asked Muhammad: Is it only another name for #pragma once?   There were reasons, why #pragma once has not been standardized so far.   What new ideas do you both bring into the discussion? That it starts with #include and is easier to scan for humans or is easier scan for computers (not the case)?   Or is your suggestion different than Muhammad's? Muhammad suggested #include once instead of #pragma once. Are you suggesting #include_once or are you suggesting #include_once "file"?   -----Ursprüngliche Nachricht----- Von:Filip <fph2137_at_[hidden]> Gesendet:So 23.03.2025 12:55 Betreff:Re: [std-proposals] #pragma once safer alternative An:std-proposals_at_[hidden]; CC:Sebastian Wittmeier <wittmeier_at_[hidden]>; std-proposals_at_[hidden]; I think it’s a great idea to add something like: #include_once  In my opinion it would be easier to use since you could look only at your included files and know immediately that it is only included once.  Something like that would be difficult to articulate to the community and maybe committee since modules overlap with this functionality of import/include. But people are not updating or changing the way they program so eagerly, changing include to include_once would be easy to make with immediate effect.  I don’t know how compiler could manage it, perhaps creating hash for each file and comparing it later with every include? Cheers, Filip Wiadomość napisana przez Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]> w dniu 23 mar 2025, o godz. 08:42:  Are you talking about #include being differently handled by the pre-processor than #pragma? And/or about different preprocessing phases and handling of macro expansion?   You are using #include once inside a condition, is this on purpose for showing some difference to #pragma once?   -----Ursprüngliche Nachricht----- Von:Muhammad via Std-Proposals <std-proposals_at_[hidden]> Gesendet:So 23.03.2025 07:34 Betreff:Re: [std-proposals] #pragma once safer alternative An:std-proposals_at_[hidden]; CC:Muhammad <mail_at_[hidden]>; OK, let's revisit #include for a minute. When the compiler hit the #include directive it will add the content of that file in-place of that directive and then will recursively scan the content for other #include for expansion. -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-03-23 12:09:05