Page 1 of 1
Compile Error. Please Help !!!
Posted: Thu Nov 08, 2001 8:52 pm
by hrr
I am a beginner. I have the files kernel.c, stdio.h, some more header files & vsprintf.c & some more .c files related to the headers in a directory. I included stdio.h in kernel.c and used vsprintf() in it. When I compile it, it gives an error in the file stdio.h at the declaretion of vsprintf(). The error is as follows :
stdio.h : parse error before 'va_list'
The declaration of the vsprintf() in stdio.h is as follows :
int vsprintf(char *buf, const char *fmt, va_list args);
The file types.h is also included in it.
What is a 'parse error' ? What is the error in the above case ?How can it be corrected ? I am using DJGPP.
[glow=blue,2,300]PLEASE HELP !!![/glow]
Re: Compile Error. Please Help !!!
Posted: Fri Nov 09, 2001 5:16 am
by thomas
a parse error occurs if theres a syntaxerror in your file eg. a forgotten ";". Check the declaration of va_list.
if it looks like:
#define arglist int
then check if theres a forbidden ";" at the end of the line:
#define arglist int;
Re: Compile Error. Please Help !!!
Posted: Mon Nov 12, 2001 5:41 am
by hrr
I fixed the problem about the va_list. The file stdarg.h had to be included in the stdio.h file. When I compiled it using gcc it gave no errors. But when I link it using ld, it gives an error in the file kernel.o saying that :
kernel.c : undefined reference to '_sprintf'
The attributes I used for linking were :
ld -Ttext 0x100000 --oformat binary -o kernel32.bin kernel.o
The function sprintf() is declared in the file stdio.h. Its code is also present in the file vsprintf.c. I tried to use vsprintf. But it gave the same error : undefined reference to '_vsprintf.c'.
How can I solve this problem ? Please help.
Re: Compile Error. Please Help !!!
Posted: Tue Nov 13, 2001 2:03 am
by df
your missing vsprintf.o in linking
Re: Compile Error. Please Help !!!
Posted: Fri Nov 16, 2001 3:16 am
by hrr
I compiled vsprintf.c to vsprintf.o. Still it gives the same error. How should I link the file to the kernel ?
Re: Compile Error. Please Help !!!
Posted: Sun Nov 18, 2001 10:05 pm
by Ranieri
> ld -Ttext 0x100000 --oformat binary -o kernel32.bin
> kernel.o vsprintf.o
Just stick vsprintf.o in there ^
Re: Compile Error. Please Help !!!
Posted: Mon Nov 19, 2001 1:14 am
by hrr
Thanks for your help. My problem is solved. I can now use sprintf in my kernel.