Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this C++ code compile?

Tags:

c++

Can someone explain to me why the following code compiles? Is it ignored by the compiler?

#include <stdio.h>
int main() {
    1234;
    return 0;
}
like image 996
MLimpkin Avatar asked May 19 '26 23:05

MLimpkin


1 Answers

The Standard obliges implementers to allow statements even with no apparent effect. This is mainly because through the magic of macros and templates, they're surprisingly easy to come up with.

like image 130
Puppy Avatar answered May 21 '26 13:05

Puppy



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!