Skip to content

A cross-platform main function for command-line programs.

License

Notifications You must be signed in to change notification settings

dgobbi/mainmacro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A main() function for cross-platform command-line programs.

This package solves two of the difficulties with porting UNIX command-line programs to Windows:

  1. It allows unicode arguments via wmain(), and converts them to utf-8.
  2. It automatically expands the wildcards * and ? in the arguments.

It is possible to turn off the wildcard expansion for certain arguments.

To use this package, simply include the "mainmacro.h" header file, and then use MAINMACRO() instead of main(), as shown in this example:

#include "mainmacro.h"

int MAINMACRO(int argc, char *argv[])
{
  // do stuff
  return 0;
}

The arguments received will be encoded as utf-8 (having been converted from the Windows-native utf-16).

Wildcard expansion will not automatically catch files that begin with ".". So if a directory contains these files:

.gitignore
file1.txt
file2.txt

Then the "dot" file will be skipped if the command is called like this:

C:\> example *
file1.txt
file2.txt

But it will not be skipped if the command is called like this:

C:\> example .*
.gitignore

About

A cross-platform main function for command-line programs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published