Search code examples
c++performanceprogram-entry-pointsignature

various C++ main() signatures and their efficiency


Recently I came across the below given code on a competetive programming website,

   #include<bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define d double
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

signed main()
{ return 0; //Omitted the rest of the code
}
[Full Code][1]

https://www.codechef.com/viewsolution/22121098

I would like to know what's the difference between this code and a regular C++ code with int main() in terms of efficiency and performance in terms of CPU speed, The problem sets are often huge.


Solution

  • signed main() is equivalent to int main() unless - like in the example - you have a macro which defines int as long long. main() has to return an int but the macro #define int long long means using the syntax int main() in this case will not compile with an error stating ::main must return int. Hence, signed main().