From 58b8d81a89ca261b67f5dcb6eb1c220c5e7d33ac Mon Sep 17 00:00:00 2001 From: Kazuho Oku Date: Sat, 9 May 2015 16:57:43 +0900 Subject: [PATCH 1/2] move qrintf.h into `include/` so that it could easily be included by `#include` --- bin/qrintf | 2 +- {share/qrintf => include}/qrintf.h | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {share/qrintf => include}/qrintf.h (100%) diff --git a/bin/qrintf b/bin/qrintf index 1a51dc0..c94020d 100755 --- a/bin/qrintf +++ b/bin/qrintf @@ -33,7 +33,7 @@ $tempfn =~ s{\.c(.*)$}{.i@{[$1 ? 'i' : '']}}s $tempfn = "$tempdir/$tempfn"; # invoke cpp -open(my $fh, "-|", $cc, '-E', (grep { $_ ne '-c' } @cflags), '-DQRINTF=1', '-include', "$pwd/../share/qrintf/qrintf.h", $fn) +open(my $fh, "-|", $cc, '-E', (grep { $_ ne '-c' } @cflags), '-DQRINTF=1', '-include', "$pwd/../include/qrintf.h", $fn) or die "failed to invoke $cc -E:$!"; my $src = do { local $/; <$fh> }; close $fh diff --git a/share/qrintf/qrintf.h b/include/qrintf.h similarity index 100% rename from share/qrintf/qrintf.h rename to include/qrintf.h From 2c92cd329b15a5e4d7ae11e591b4fcc9e2a48115 Mon Sep 17 00:00:00 2001 From: Kazuho Oku Date: Sat, 9 May 2015 17:31:29 +0900 Subject: [PATCH 2/2] do nothing in the automatic include if the `QRINTF_NO_AUTO_INCLUDE` is defined --- include/qrintf.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/qrintf.h b/include/qrintf.h index 2260936..3bf48ba 100644 --- a/include/qrintf.h +++ b/include/qrintf.h @@ -20,8 +20,17 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -#ifndef qrintf_h -#define qrintf_h +#if !defined(QRINTF_INCLUDE_COUNT) +# define QRINTF_INCLUDE_COUNT 1 +#elif QRINTF_INCLUDE_COUNT==1 +# undef QRINTF_INCLUDE_COUNT +# define QRINTF_INCLUDE_COUNT 2 +#elif QRINTF_INCLUDE_COUNT==2 +# undef QRINTF_INCLUDE_COUNT +# define QRINTF_INCLUDE_COUNT 3 +#endif + +#if (!defined(QRINTF_NO_AUTO_INCLUDE) && QRINTF_INCLUDE_COUNT==1) || (defined(QRINTF_NO_AUTO_INCLUDE) && QRINTF_INCLUDE_COUNT==2) #ifdef __cplusplus extern "C" {