Compile Error. Please Help !!!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
hrr

Compile Error. Please Help !!!

Post 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]
thomas

Re: Compile Error. Please Help !!!

Post 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;
hrr

Re: Compile Error. Please Help !!!

Post 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.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: Compile Error. Please Help !!!

Post by df »

your missing vsprintf.o in linking
-- Stu --
hrr

Re: Compile Error. Please Help !!!

Post by hrr »

I compiled vsprintf.c to vsprintf.o. Still it gives the same error. How should I link the file to the kernel ?
Ranieri

Re: Compile Error. Please Help !!!

Post by Ranieri »

> ld -Ttext 0x100000 --oformat binary -o kernel32.bin
> kernel.o vsprintf.o

Just stick vsprintf.o in there ^ ;-)
hrr

Re: Compile Error. Please Help !!!

Post by hrr »

Thanks for your help. My problem is solved. I can now use sprintf in my kernel.
Post Reply