Can I write a program in C or in C++ with two main functions?
The idiom is to dispatch on the value of argv[0]. With hardlinks (POSIX) you don't even lose diskspace.
argv[0]