Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can using 0L to initialize a pointer in C++ cause problems?

In this question an initializer is used to set a pointer to null. Instead of using value of 0 value of 0L is used. I've read that one should use exactly 0 for null pointers because exact null pointer representation is implementation-specific.

Can using 0L to set a pointer to null cause problems while porting?

like image 472
sharptooth Avatar asked Mar 19 '26 03:03

sharptooth


1 Answers

From the standard (4.10.1):

A null pointer constant is an integral constant expression (5.19) rvalue of integer type that evaluates to zero

so I guess 0L is ok.

like image 133
Andreas Brinck Avatar answered Mar 21 '26 18:03

Andreas Brinck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!