Would redefining keywords cause any errors?

I’ve seen many people do this in competitive programming:

#define int long long int

And also this:

#define endl ‘\n’

Is this considered as a good practice and would this cause any errors?

In professional development - God no XD. The former is Undefined Behaviour (see e.g. C++ preprocessor #define-ing a keyword. Is it standards conforming? - Stack Overflow) (and note that int main() now becomes illegal(!)). For the latter, see e.g. WA for Interactive Problem - #3 by ssjgz.

In competitive programming - lots of people who do well at it use it, so … meh.

3 Likes