Also, I get this warning from gcc (cross compiler) which I didn't have in linux (non cross compiler)
Code: Select all
note: if this code is reached, the program will abort.
Code: Select all
void kprintf(char str[], ...)
{
va_list listptr;
va_start(listptr, str);
short is_percent = 0;
register int i = 0;
for(; i < strlen(str); i++)
{
if(str[i] == '%')
{
is_percent = 1;
continue;
}
if(is_percent)
{
switch(str[i])
{
case 'd':
putnum(va_arg(listptr, int));
break;
case 'c':
putch(va_arg(listptr, unsigned char)); //Faulty line, all others work.
break;
case 'x':
puthex(va_arg(listptr, unsigned int));
break;
case 's':
puts(va_arg(listptr, char*));
break;
case 'u':
putunum(va_arg(listptr, unsigned long));
break;
}
is_percent = 0;
}
else
{
putch(str[i]);
}
}
}
Code: Select all
#define va_start(v,l) __builtin_va_start(v,l)
#define va_arg(v,l) __builtin_va_arg(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_copy(d,s) __builtin_va_copy(d,s)
typedef __builtin_va_list va_list;