Remy Lebeau 1396 Posted March 4, 2023 (edited) 18 hours ago, alank2 said: Clang-enhanced C++ compilers do not allow the use of sizeof in a preprocessor directive, such as #if sizeof(ATypeName) > 20. How can one then test for sizes if this is not an option - is there a workaround/alternative method? Tons of questions on StackOverflow on that very topic, for instance: How can I use "sizeof" in a preprocessor macro? sizeof() is not executed by preprocessor Does the sizeof operator work in preprocessor #if directives? Just to name a few... 10 hours ago, Roger Cigol said: You can use if (sizeof(ATypeName) > 20) { /*.... your code here ...*/ } in your code (ie it's just the preprocessor #if form that is not handled) Since sizeof is a compile-time constant, I would use "if constexpr" instead: if constexpr (sizeof(ATypeName) > 20) { /*.... your code here ...*/ } Edited March 4, 2023 by Remy Lebeau 1 Share this post Link to post
Roger Cigol 103 Posted March 4, 2023 A definite improvement - thanks Remy. Share this post Link to post