I'm trying to use gpp (Generic Preprocessor) to add some additional information before and after an #include. The code is as follows:

\define{\code{filename}}{PRE \include{\filename} POST} ==> \code{./t.txt} <==

And the output:

$ gpp -T t.mkd -o t.out t.mkd:2: error: Requested include file not found

I'm thinking there's a problem with referencing \filename with \include as \filename will only be evaluated once \code is called while meta-macros will store their parameters at define time (If I understand the documentation correctly).

I've tried a bunch of different stuff, and while this is obviously a RTFM kind of question, my intended use of the tool is too limited to justify using a whole lot of time learning the tool (and not just try another preprocessor and another until one just works well enough - I started testing with gpp as it seems quite capable if we need more later).

PS: Sorry about the lack of relevant tags. I don't have enough reputation to create tags, and the only one that popped up was macro.


You might get more useful responses for this question on StackOverflow than on SuperUser.

In the meantime, however, given that the latest version of gpp was released in 2004, it might be difficult to find people with expertise in it to assist you. If using another preprocessor would be an option, I'd suggest m4, for which the GNU version is regularly updated and widely used -- especially as part of the GNU autoconf software. In m4 the equivalent code (in the file t.m4) would be:

define(`code',`PRE include(`$1') POST')dnl

Given a file t.txt that reads:

This is the content of the file t.txt.

... the command m4 t.m4 produces:

PRE This is the content of the file t.txt.
  • Guess we'll go with m4 then. They also have an installer for Windows users which is good. Thanks.
    – simendsjo
    Jan 8 '15 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.