# 'va_list' undeclared (first use in this function)



## luo (Jan 4, 2012)

In my driver, I use 'va_list' type to define variable, but, the compiler reports the following error:

```
'va_list' undeclared (first use in this function)
```
Which header file should I include?

thanks


----------



## SirDice (Jan 4, 2012)

You can't use C library functions (or macros) within the kernel and, as a consequence, in a driver.


----------



## doena (Jan 4, 2012)

> You can't use C library functions (or macros) within the kernel and, as a consequence, in a driver.



I think that's not true and he's only missing the line:

```
#include <machine/stdarg.h>
```

Because va_list is used all over the drivers- and kernel-code.


----------



## SirDice (Jan 4, 2012)

It might have been defined specifically in the kernel sources but my statement is still true.


----------



## fonz (Jan 4, 2012)

To clarify: what SirDice probably tries to say (and he's absolutely right about that) is that driver and kernel code should not use userland libraries. However, if (some form of) stdarg is also available in the kernel source tree then it's perfectly fine to use that; just include the right header file and hack away.

Fonz

P.S. If I'm not mistaken, stdarg consists solely of macros, so in this case there shouldn't be any problems as long as one includes the right header file.


----------



## luo (Jan 5, 2012)

```
#include <machine/stdarg.h>
```
 can work.
Thanks doena and everyone.


----------

