I want to improve the readability of the code. So I commented the parameter's direction in the code like this:
#define IN
#define OUT
void Add(IN int Para1, IN int Para2, OUT int& Result);
But I think the compiler will replace every instance of IN and OUT with blank and it could be quite a problem some times.
So is there a better way? Thanks.
(I use C++.)
Yes: Forget those things and use constness. That will work as long as you don't have a "in" and "out" parameter, which is and should be rarely used.
void foo(int i, const std::string& s, std::vector<char>& out_buf);
// i and s are obviously "in" variables, while out_buf could be both,
// but you can easily show that by giving the parameter a proper name.
Edit: And const correctness does not mean to make value parameters const! This doesn't give the caller any additional information at all, since you can't change his variables either way.