# printf.h: include error, missing FILE definition



## naota (Nov 17, 2010)

Hello,

I found that compiling the following code occur some errors.


```
#include <printf.h>

int main() { return 0; }
```

and the errors are:


```
In file included from foo.c:1:
/usr/include/printf.h:102: error: expected ')' before '*' token
/usr/include/printf.h:117: error: expected ')' before '*' token
/usr/include/printf.h:121: error: expected declaration specifiers or '...' before 'printf_function'
```

It seems <printf.h> forget to define "FILE". Yes, I know we can solve these errors by including <stdio.h> before <printf.h>. But isn't it still a bug or misfeature?


----------



## SirDice (Nov 17, 2010)

As far as I can see printf.h only redefines printf() (and similar functions). It doesn't do much else. That's why you still need stdio.h.


----------



## naota (Nov 18, 2010)

You mean <printf.h> always should be include'd after <stdio.h>?
Then I think it would be better to include <stdio.h> in <printf.h>


----------



## kpa (Nov 18, 2010)

You shouldn't include printf.h directly at all in your programs, it might go away at the next version of the operating system. On the other hand stdio.h is one the standard C language header files and is guaranteed to be available regardless of compiler and operating system used.


----------



## naota (Nov 18, 2010)

kpa said:
			
		

> You shouldn't include printf.h directly at all in your programs, it might go away at the next version of the operating system. On the other hand stdio.h is one the standard C language header files and is guaranteed to be available regardless of compiler and operating system used.



Really? Then what should I use if I really want to use "register_printf_function" or "struct printf_info"?
I know stdio.h provides printf() or such things. But it doesn't provide the above function and struct, so including just stdio.h doesn't solve the problem.


----------



## kpa (Nov 18, 2010)

Those are implementation details that you normally don't want to know about when writing application programs, why are you writing code that depends on such details?


----------



## naota (Nov 19, 2010)

Actually, I'm compiling gstreamer-0.10.30 by my hand (not using ports) and get the error above. It seems gstreamer uses register_printf_function to add extra information to debug printings. I'd like to fix it but not to change the behavior so much, but maybe it would be better to ask gstreamer team now.


----------

