Final Platform Layer  0.9.6-beta
How to disable the use of the CRT in FPL

Consequences of disabling the CRT

If you disable the CRT, you lose a lot of functionality which we today take for granted:

  • No functions from the entire C standard library stack, such as "stdio.h" / "stdlib", / "math.h" / "string.h", etc.
  • No or limited integer mul/div operations on some platforms
  • No console input/output
  • No C++ exceptions
  • Limited security checks
  • No automatic entry point mapping to main() or WinMain()
  • Limited floating point operations on some platforms
  • Limited stack size

Some limitations can be corrected by setting up the compiler properly, such as stack size, security checks, etc.

So if you are fine with that, the next section describes how to do disable the CRT usage in FPL.

Requirements for disabling the CRT in FPL

  • You have read the Consequences of disabling the CRT
  • You know what you are doing
  • You already disabled the CRT by compiler settings
  • You fixed the security checks and stack size by compiler settings

Disable the CRT in FPL

To disable the use of the C-Runtime Library, you need to set certain preprocessor definitions:

  • Define FPL_NO_CRT in all translation units where FPL implementation is included
  • In your main translation-unit, you need to define the application type FPL_APPTYPE_CONSOLE or FPL_APPTYPE_WINDOW explicitly
#define FPL_NO_CRT // Disable CRT support in FPL
#define FPL_APPTYPE_CONSOLE // or FPL_APPTYPE_WINDOW
#define FPL_IMPLEMENTATION // FPL_NO_CRT must be set set in the implementation only
#include <final_platform_layer.h>

Providing intrinsics (Mini-CRT)

Some compilers such as MSVC require certain stuff to compile properly.
You are responsible to provide that stuff if you get compile errors.

A few errors you may get:

Runtime check:

  • unresolved external symbol __RTC_Shutdown
  • unresolved external symbol __RTC_InitBase
  • unresolved external symbol __RTC_CheckEsp
  • unresolved external symbol __RTC_CheckStackVars

Float:

  • unresolved external symbol __fltused -> Global used in MSVC
  • unresolved external symbol __ltod3 -> Double division intrinsic

Integer:

  • unresolved external symbol __allmul -> Long-Long integer multiplication intrinsic

Other:

  • unresolved external symbol __memset -> memset intrinsic (May use fplMemorySet)
  • unresolved external symbol __memcpy -> memcpy intrinsic (May use fplMemoryCopy)

To solve those compile errors it is recommended to use a mini-crt library or write all the functions yourself.

Notes

Right now FPL has No-CRT support for Win32 only! If you need this for other platforms let me know.