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]
Compile Error. Please Help !!!
Re: Compile Error. Please Help !!!
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;
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 !!!
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.
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 !!!
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 !!!
> ld -Ttext 0x100000 --oformat binary -o kernel32.bin
> kernel.o vsprintf.o
Just stick vsprintf.o in there ^
> kernel.o vsprintf.o
Just stick vsprintf.o in there ^
Re: Compile Error. Please Help !!!
Thanks for your help. My problem is solved. I can now use sprintf in my kernel.