Dear Bram, dear Tony sorry for responding so late -- since I have a job, I run out of time very often. Maybe I am not making enough use of all the possibilities of vim ...
>>> I inspected if_perl.xs and if_perl.c and saw that xsubpp simply removed >>> preprocessor directives such as >>> >>>> ! #ifdef FEAT_AUTOCMD >>>> >>> out of the code without really make a decision between the #if or #else: >>> Both parts were left. >>> >> I missed this, it compiles OK for me even though the code is wrong. >> Note that I put some white space before the # to make it work for me. >> I noted the space: Alas, xsubpp does not :-( >>> I then found >>> >>> http://perldoc.perl.org/perlxs.html#Inserting-POD%2c-Comments-and-C-Preprocessor-Directives >> >> But that mentions that the preprocessor directives are passed on >> unmodified... That isn't so, this documentation is wrong. > Maybe, I misunderstood the documentation and, based on this, did something that worked. But I thought that this statement is valid only before the "MODULE line" -- before the line that much the regular expression ^\s*MODULE\s*=.*\s\s*PACKAGE\s*=.*$ After that line, the text that begins with "If you use preprocessor directives to choose one of two versions of a function [...]" becomes valid. >> Your solution to duplicate the functions is not nice. >> Yes, it's not nice, it's only a work around until a better solution is found. > Compiling on SuSE 9.3 with gcc 3.3.5 20050117 (prerelease), I also get > no messages for if_perl although the # lines are removed and both > branches (before and after #else) passed on. > The code that results if the directives are cancelled is valid C++, but is not valid C. Maybe that this is the crucial point. > I notice that # directives of all kinds are passed on unmodified > elsewhere in the code; but they have the # in column 1 (sometimes with > spaces after the #). There is also one "# string" in a /* comment */ > which is passed on OK. Maybe xsubpp doesn't recognise lines with spaces > before # as 'preprocessor directives' to be passed on? > I think this is not the point. Since I have no time for quickly trying things out, I can only tell about my speculations: Before the "MODULE line" (see above), # directives are passed unmodified, after that "MODULE line" they are interpreted by xsubpp. My suggestion is to pass the if_perl.xs file first though a C preprocessor, and only after that through xsubpp. If the preprocessor disturb the format of if_perl.xs too much so it can't be parsed by xsubpp anymore, I would try something like rename if_perl.xs to if_perl.xs.orig pre-process if_perl.xs.orig to if_perl.xs.pp copy lines before "MODULE line" from f_perl.xs.orig to if_perl.xs add lines after "MODULE line" form if_perl.xs.pp to if_perl.xs xsubpp if_perl.xs But this are only my speculations ... Best regards Mathias