Can we write a portable include guard that doesn’t use the preprocessor in C++? If so how could that be done?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
#includewithout the preprocessor.There are a couple non-portable ways to do this (both use the preprocessor), such as:
and
But header guards work everywhere, and your compiler is probably optimized to check for header guards so it won’t even bother processing a duplicate
#includedirective.