Skip to content

matveyt/nocrt0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nocrt0

Summary

Custom C startup code (mainCRTStartup) implementation for GCC/MinGW.

Description

Nocrt0 is a custom C startup code without any dependencies of the standard C runtime libraries. It is intended for building very small executable files under OS Windows(R). Nocrt0 was successfully tested with GCC/MinGW 7.2.0 and Pelles C 8.0. It is also possible that nocrt0 could be adapted for other C compilers, including Microsoft Visual C, as well, however, the source code requires some of C99 language features, so it cannot be compiled with msvc directly.

Using nocrt0

There are two modules: nocrt0w for GUI applications, and nocrt0c for console applications. Simply add the correct source into your project and build it without linking to the default C startup code (hint: for GCC you will need nostdlib or nostartfiles option).

The process of building nocrt0 can also be controlled with the following DEFINEs:

-D_UNICODE
-DARGV={own | msvcrt | none}

_UNICODE builds "wide" version of the startup code (wmain or wWinMain).

ARGV is used for a console application (nocrt0c) only. It selects the type of the underlying implementation of the standard command-line parser (argc/argv). own (default) is the built-in implementation (note: envp is not supported and is always set to NULL); msvcrt makes use of an external function __getmainargs() (which is normally imported from msvcrt.dll); none is intended for applications which do not need any command-line processing (int main(void)).

GCC note: nocrt0 includes the internal assembly (both x86 and x86-64) implementation of __alloca function. That means you shouldn't link your application with libgcc.a. If it's undesirable you have to patch the source code first.

About

Custom C startup code for GCC/MinGW

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages