@@ -154,6 +154,11 @@ macro ropecg(m: BModule, frmt: static[FormatStr], args: untyped): Rope =
154154 inc (i)
155155 result .add newCall (formatValue, resVar, args[num])
156156 inc (num)
157+ of '^' :
158+ flushStrLit ()
159+ inc (i)
160+ result .add newCall (formatValue, resVar, args[^ 1 ])
161+ inc (num)
157162 of '0' .. '9' :
158163 var j = 0
159164 while true :
@@ -1366,7 +1371,7 @@ proc genMainProc(m: BModule) =
13661371 " }$N$N"
13671372
13681373 MainProcs =
1369- " \t NimMain ();$N"
1374+ " \t $^NimMain ();$N"
13701375
13711376 MainProcsWithResult =
13721377 MainProcs & (" \t return $1nim_program_result;$N" )
@@ -1376,7 +1381,7 @@ proc genMainProc(m: BModule) =
13761381 " }$N$N"
13771382
13781383 NimMainProc =
1379- " N_CDECL(void, NimMain )(void) {$N" &
1384+ " N_CDECL(void, $5NimMain )(void) {$N" &
13801385 " \t void (*volatile inner)(void);$N" &
13811386 " $4" &
13821387 " \t inner = NimMainInner;$N" &
@@ -1456,28 +1461,27 @@ proc genMainProc(m: BModule) =
14561461 if optGenGuiApp in m.config.globalOptions:
14571462 const nimMain = WinNimMain
14581463 appcg (m, m.s[cfsProcs], nimMain,
1459- [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode])
1464+ [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode, m.config.nimMainPrefix ])
14601465 else :
14611466 const nimMain = WinNimDllMain
14621467 appcg (m, m.s[cfsProcs], nimMain,
1463- [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode])
1468+ [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode, m.config.nimMainPrefix ])
14641469 elif m.config.target.targetOS == osGenode:
14651470 const nimMain = GenodeNimMain
14661471 appcg (m, m.s[cfsProcs], nimMain,
1467- [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode])
1472+ [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode, m.config.nimMainPrefix ])
14681473 elif optGenDynLib in m.config.globalOptions:
14691474 const nimMain = PosixNimDllMain
14701475 appcg (m, m.s[cfsProcs], nimMain,
1471- [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode])
1476+ [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode, m.config.nimMainPrefix ])
14721477 elif m.config.target.targetOS == osStandalone:
14731478 const nimMain = NimMainBody
14741479 appcg (m, m.s[cfsProcs], nimMain,
1475- [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode])
1480+ [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode, m.config.nimMainPrefix ])
14761481 else :
14771482 const nimMain = NimMainBody
14781483 appcg (m, m.s[cfsProcs], nimMain,
1479- [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode])
1480-
1484+ [m.g.mainModInit, initStackBottomCall, m.labels, preMainCode, m.config.nimMainPrefix])
14811485
14821486 if optNoMain notin m.config.globalOptions:
14831487 if m.config.cppCustomNamespace.len > 0 :
@@ -1487,23 +1491,22 @@ proc genMainProc(m: BModule) =
14871491 m.config.globalOptions * {optGenGuiApp, optGenDynLib} != {}:
14881492 if optGenGuiApp in m.config.globalOptions:
14891493 const otherMain = WinCMain
1490- appcg (m, m.s[cfsProcs], otherMain, [if m.hcrOn: " *" else : " " ])
1494+ appcg (m, m.s[cfsProcs], otherMain, [if m.hcrOn: " *" else : " " , m.config.nimMainPrefix ])
14911495 else :
14921496 const otherMain = WinCDllMain
1493- appcg (m, m.s[cfsProcs], otherMain, [])
1497+ appcg (m, m.s[cfsProcs], otherMain, [m.config.nimMainPrefix ])
14941498 elif m.config.target.targetOS == osGenode:
14951499 const otherMain = ComponentConstruct
1496- appcg (m, m.s[cfsProcs], otherMain, [])
1500+ appcg (m, m.s[cfsProcs], otherMain, [m.config.nimMainPrefix ])
14971501 elif optGenDynLib in m.config.globalOptions:
14981502 const otherMain = PosixCDllMain
1499- appcg (m, m.s[cfsProcs], otherMain, [])
1503+ appcg (m, m.s[cfsProcs], otherMain, [m.config.nimMainPrefix ])
15001504 elif m.config.target.targetOS == osStandalone:
15011505 const otherMain = StandaloneCMain
1502- appcg (m, m.s[cfsProcs], otherMain, [])
1506+ appcg (m, m.s[cfsProcs], otherMain, [m.config.nimMainPrefix ])
15031507 else :
15041508 const otherMain = PosixCMain
1505- appcg (m, m.s[cfsProcs], otherMain, [if m.hcrOn: " *" else : " " ])
1506-
1509+ appcg (m, m.s[cfsProcs], otherMain, [if m.hcrOn: " *" else : " " , m.config.nimMainPrefix])
15071510
15081511 if m.config.cppCustomNamespace.len > 0 :
15091512 m.s[cfsProcs].add openNamespaceNim (m.config.cppCustomNamespace)
@@ -1885,7 +1888,7 @@ proc writeHeader(m: BModule) =
18851888
18861889 if optGenDynLib in m.config.globalOptions:
18871890 result .add (" N_LIB_IMPORT " )
1888- result .addf (" N_CDECL(void, NimMain )(void);$n" , [])
1891+ result .addf (" N_CDECL(void, $1NimMain )(void);$n" , [rope m.config.nimMainPrefix ])
18891892 if m.config.cppCustomNamespace.len > 0 : result .add closeNamespaceNim ()
18901893 result .addf (" #endif /* $1 */$n" , [guard])
18911894 if not writeRope (result , m.filename):
0 commit comments