summary refs log tree commit diff stats
path: root/compiler/cgen.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/cgen.nim')
-rwxr-xr-xcompiler/cgen.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index e9d7673bb..d85d3fe53 100755
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -778,6 +778,9 @@ proc genMainProc(m: BModule) =
     PosixCMain = "int main(int argc, char** args, char** env) {$n" &
         "  cmdLine = args;$n" & "  cmdCount = argc;$n" & "  gEnv = env;$n" &
         "  NimMain();$n" & "  return nim_program_result;$n" & "}$n"
+    StandaloneCMain = "int main(void) {$n" &
+        "  NimMain();$n" & 
+        "  return 0;$n" & "}$n"
     WinNimMain = "N_CDECL(void, NimMain)(void) {$n" &
         CommonMainBody & "}$n"
     WinCMain = "N_STDCALL(int, WinMain)(HINSTANCE hCurInstance, $n" &
@@ -807,7 +810,10 @@ proc genMainProc(m: BModule) =
   elif optGenDynLib in gGlobalOptions:
     nimMain = posixNimDllMain
     otherMain = posixCDllMain
-  else: 
+  elif platform.targetOS == osStandalone:
+    nimMain = PosixNimMain
+    otherMain = StandaloneCMain
+  else:
     nimMain = PosixNimMain
     otherMain = PosixCMain
   if gBreakpoints != nil: discard cgsym(m, "dbgRegisterBreakpoint")