Jump to content
alank2

Is there a way to use a platform specific win32/win64 DEF file?

Recommended Posts

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 by Remy Lebeau
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×