### vkditya0997's blog

By vkditya0997, history, 5 years ago,

Hello Everyone,

What's the difference in these two macros ?

#define LL long long int
and
typedef long long LL;


and

What's the difference between these ?

inline void myFunction(){}
and
void myFunction(){}


Thanks !

• -6

 » 5 years ago, # |   +1 Auto comment: topic has been updated by vkditya0997 (previous revision, new revision, compare).
 » 5 years ago, # |   +18 For the first one look here. define is low-level preprocessing construct which will blindly replace all LL tokens with long long int regardless of their meaning before compiler even gets a chance to take a look at the code. typedef works on compiler level, it tells compiler to make a new type called LL and make it same as long long, so it won't screw up some other places (see the link for a good example).For the second one: here. Actually, there is little difference: inline suggests that compiler inline that function wherever it's called instead of pushing arguments to stack and making a jump, can save some time. But it's still only suggestion, compiler is free to do anything it wants: both discard inline modifier and inline function without that modifier. There is some serious difference on linking stage, but that does not matter in competitive programming.
•  » » 5 years ago, # ^ |   0 Some contestants inline every function they use. Is it appropriate?
•  » » » 5 years ago, # ^ |   +8 It does not hurt.
 » 5 years ago, # |   +32 Inline? Check this vs this.
 » 5 years ago, # |   +20 One clear practical difference is that names introduced by #define cannot be used in other contexts in the program. For example: #define LL long long int void foo(void) { int LL = 13; // <- compilation error here } 
•  » » 5 years ago, # ^ |   +22 Wow, you made my day. Until now I thought that this would not compile with typedef either, but all this C++ namespace and scope stuff can sometimes be ridiculous.The code below compiles successfully (at least by g++4-8): #include typedef long long i64; int main() { int i64 = 1; std::cout << (::i64)i64 << std::endl; } 
•  » » » 5 years ago, # ^ | ← Rev. 2 →   +11 Standard name lookup rules apply to your example. It compiles for the same reason why the next example compiles — because the inner scope is always looked up first unless the :: operator is used: int i = 1; int main() { long i = 2; cout << i << " " << ::i << endl; } And the other way around: trying to define a variable and a type in the same scope with the same name leads to an error. typedef long long i64; int i64 = 1; // <- error