Add option 'PRINTF_ONLY_FCTPRINTF' to compile the library without functions that depend on putchar_. #206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To resolve #203: When the CMake cache variables is enabled / when the equivalent define is set, the main header only exposes fctprintf and vfctprintf.
Only when the CMake cache variable is set are all other functions (those that depend on putchar_) not compiled into the library. This is to stay consistent with the way other options are currently handled, although I feel like this might be a design flaw, and it would be better to have printf.h unconditionally include the config header, which then would also need to be installed.
To separate the functionality cleanly, and to allow linking with the entire (static) library even when it wasn't built with the new flag without having to define putchar_, I split the functionality into two translation units. All code shared between the two TUs is in a new header internal.h.
This begs another question: Should I move the main header emtest.h into a separate include directory, and make only that one publicly accessible with target_include_directories?
Right now if a consumer of the libary adds the project as a subdirectory, then linking with the target allows them to include "printf/internal.h" which
(a) is probably undesirable, and
(b) when installing the library the header is not installed, so it can't be included
Incidentally this was already possible with the source file printf.c. Although I doubt any user will have done
#include <printf/printf.c>, it is technically a backwards-compatibility problem.