When you're using a scripting mode - "-s", "-m" or "-i" - it now automatically includes all the system headers for you.

This fixes issue 101

git-svn-id: http://picoc.googlecode.com/svn/trunk@475 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2010-07-27 11:48:39 +00:00
parent c0a21f5c37
commit 0ffbd21f2e
3 changed files with 16 additions and 3 deletions

View file

@ -5,7 +5,7 @@
/* a list of libraries we can include */
struct IncludeLibrary
{
const char *IncludeName;
char *IncludeName;
void (*SetupFunction)(void);
struct LibraryFunction *FuncList;
const char *SetupCSource;
@ -57,6 +57,14 @@ void IncludeRegister(const char *IncludeName, void (*SetupFunction)(void), struc
IncludeLibList = NewLib;
}
/* include all of the system headers */
void IncludeAllSystemHeaders()
{
struct IncludeLibrary *ThisInclude = IncludeLibList;
for (; ThisInclude != NULL; ThisInclude = ThisInclude->NextLib)
IncludeFile(ThisInclude->IncludeName);
}
/* include one of a number of predefined libraries, or perhaps an actual file */
void IncludeFile(char *FileName)

View file

@ -67,21 +67,25 @@ int main(int argc, char **argv)
if (argc < 2)
{
printf("Format: picoc <csource1.c>... [- <arg1>...] : run a program (calls main() to start it)\n"
" picoc -m <csource1.c>... [- <arg1>...] : run a program without calling main()\n"
" picoc -s <csource1.c>... [- <arg1>...] : script mode - runs the program without calling main()\n"
" picoc -i : interactive mode\n");
exit(1);
}
Initialise();
if (strcmp(argv[ParamCount], "-m") == 0)
if (strcmp(argv[ParamCount], "-s") == 0 || strcmp(argv[ParamCount], "-m") == 0)
{
DontRunMain = TRUE;
IncludeAllSystemHeaders();
ParamCount++;
}
if (strcmp(argv[ParamCount], "-i") == 0)
{
IncludeAllSystemHeaders();
ParseInteractive();
}
else
{
if (PlatformSetExitPoint())

View file

@ -437,6 +437,7 @@ void IncludeInit();
void IncludeCleanup();
void IncludeRegister(const char *IncludeName, void (*SetupFunction)(void), struct LibraryFunction *FuncList, const char *SetupCSource);
void IncludeFile(char *Filename);
void IncludeAllSystemHeaders();
/* stdio.c */
extern const char StdioDefs[];