has nothing to do with volatile. int and long themselves are of different types (can have different lengths). Of course you will get an error if you pass it off like this. First check whether there is any problem with the logic of your code, and then use type conversion with caution.
No error will be reported in C, but there will be a warning:
The reason for the warning is clear, int and long are incompatible. An error will be reported in C++ because C++'s type system is more strict.
Please label the question correctly to avoid attracting non-professional people and wasting both parties’ time.
has nothing to do with
volatile
.int
andlong
themselves are of different types (can have different lengths). Of course you will get an error if you pass it off like this. First check whether there is any problem with the logic of your code, and then use type conversion with caution.