X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Ffunction.c;h=c4f30ca499bdac676ad0443ec17c5d802c7c108a;hb=f7dfcbcc3daf8426770842b5e6ed3634e0d50c82;hp=e4dbe83d854cec6292b8603be8a1b53765c4aa3d;hpb=086d80e8c439fa7e6846b34c4848355d04efdd5c;p=cc65 diff --git a/src/cc65/function.c b/src/cc65/function.c index e4dbe83d8..c4f30ca49 100644 --- a/src/cc65/function.c +++ b/src/cc65/function.c @@ -6,9 +6,9 @@ /* */ /* */ /* */ -/* (C) 2000-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ +/* (C) 2000-2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ /* */ @@ -369,6 +369,22 @@ void NewFunc (SymEntry* Func) /* Allocate code and data segments for this function */ Func->V.F.Seg = PushSegments (Func); + /* Special handling for main() */ + if (strcmp (Func->Name, "main") == 0) { + /* Main cannot be a fastcall function */ + if (IsFastCallFunc (Func->Type)) { + Error ("`main' cannot be declared as __fastcall__"); + } + + /* If main() takes parameters, generate a forced import to a function + * that will setup these parameters. This way, programs that do not + * need the additional code will not get it. + */ + if (D->ParamCount > 0 || (D->Flags & FD_VARIADIC) != 0) { + g_importmainargs (); + } + } + /* If this is a fastcall function, push the last parameter onto the stack */ if (IsFastCallFunc (Func->Type) && D->ParamCount > 0) {