Defintion in TinyFAT conflicts with stdio.h

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using TinyFAT (tff.h / tff.c) and I'm also using the snprintf() function. When I include stdio.h into my program I get all sorts of errors that TinyFAT is already declaring functions like fputc(), feof, EOF etc.

If I don't include stdio.h my project builds but I get a warning that snprintf() is implicitly declared. I reckon it finds the object code during the link anyway.

Is there any way to work around the problems when including stdio.h?

Thank you for your response.

Building my dreams!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Something wrong with your copy of tff.h/tff.c? - mine don't have defintiions of either EOF or fputc()

Can you post the exact error message the compiler is showing? It should identify the files and line numbers where the redefinition occurs.

Are you SURE you aren't #include'ing a .c file somewhere?

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The definitions are present in my copy of tff.h.

I think I solved it: in tff.h I set the define

_USE_STRFUNC

to 0. It then doesn't compile fputs(), EOF etc.

Thanks for the help!

Building my dreams!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Aaargh! I thought I solved it, but I didn't. I need to set _USE_STRFUNC to 1 since I need f_printf(). I use it to write to a file on the MMC.

The includes:

#include 
#include 
#include  
#include 
#include       // bool type
#include 
#include 
#include "tff.h"              // FAT file system core
#include "diskio.h"           // FAT system functions

The errors:

In file included from ../H14Firmware.c:31:
../tff.h:182:1: warning: "feof" redefined
In file included from ../H14Firmware.c:25:
C:\WinAVR\avr\include/stdio.h:861:1: warning: this is the location of the previous definition
In file included from ../H14Firmware.c:31:
../tff.h:183:1: warning: "EOF" redefined
In file included from ../H14Firmware.c:25:
C:\WinAVR\avr\include/stdio.h:312:1: warning: this is the location of the previous definition
In file included from ../H14Firmware.c:31:
../tff.h:184: error: conflicting types for 'fputc'
../tff.h:185: error: conflicting types for 'fputs'
../tff.h:186: error: conflicting types for 'fprintf'
../tff.h:187: error: conflicting types for 'fgets'
C:\WinAVR\avr\include/stdio.h:822: error: previous declaration of 'fgets' was here
../H14Firmware.c: In function 'WriteSensorValuesToMemoryCard':
../H14Firmware.c:653: warning: implicit declaration of function 'f_printf'
make: *** [H14Firmware.o] Error 1
Build failed with 5 errors and 5 warnings...

Building my dreams!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wonder if you have a different version?

D:\USB stick\fatfs\src>dir
 Volume in drive D is DATA
 Volume Serial Number is 3636-53FD

 Directory of D:\USB stick\fatfs\src

25/11/2008  17:02              .
25/11/2008  17:02              ..
05/05/2007  01:27             6,031 00readme.txt
31/03/2007  21:45             1,556 diskio.h
05/05/2007  01:04            58,808 ff.c
05/05/2007  01:12            11,050 ff.h
27/03/2007  00:35               582 integer.h
05/05/2007  01:04            49,475 tff.c
05/05/2007  01:12             9,624 tff.h
               7 File(s)        137,126 bytes
               2 Dir(s)   9,521,373,184 bytes free

D:\USB stick\fatfs\src>grep fputs *

D:\USB stick\fatfs\src>

(so nothing in my set of files admits to "fputs" at all?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using Tiny-FatFs R0.06 and the current release of FatFS is R0.07. Both of these have EOF and puts() defined. So I guess you have an older version (should be at the top of the file).

For some reason I can't find Tiny-FatFs R 0.07. Maybe they got rid of it.

Building my dreams!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got it fixed. Moved to the latest version of FatFs and set _USE_STRFUNC to '2'.

No warnings and no errors even if I include stdio.h.

Thanks!

Building my dreams!