__has_include_ causes compilation errors
hi greiman!
Problem: I have noticed in SdFat.h, from version 2.0.2 onwards, that _has_include causes a compiler error. I am using Stalker V3.1 board that runs on AT Mega 328P.
Proposed solution: Use _has_include differently to make the code portable (not sure how this affects functionality of your code):
#if __has_include
# if !__has_include(<FS.h>))
typedef File32 File;
# endif
#endif
I didn't write the test in SdFat.h, it was provided by Paul Sofgren for Teensy boards.
The problem with your code is that it may not work if __has_include is not defined.
#if __has_include should not be used in that case.
gcc documentation:
The __has_include operator by itself, without any operand or parentheses, acts as a predefined macro so that support for it can be tested in portable code.
So Paul's code is not correct either.
#if defined __has_include is needed with no operator or parentheses.
I will rework the code for defining File.
Perhaps something like this:
#if defined __has_include
# if __has_include (<FS.h>)
# define HAS_FS_H
# endif
#endif
#ifndef HAS_FS_H
// define File here
#endif