[ 
https://issues.apache.org/jira/browse/LUCY-71?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12805713#action_12805713
 ] 

Marvin Humphrey commented on LUCY-71:
-------------------------------------

It turns out that the following construct generates a warning under GCC:

{code:none}
char stuff[] = QUOTE(\
  #include <stdio.h>
  int main() {
    printf("Greetings, earthlings.\n");
    return 0;
  }
);
{code}

"foo.c:23:5: warning: embedding a directive within macro arguments is not 
portable"

Thus, my forthcoming patch takes this tack instead:

{code:none}
char stuff[] = 
  QUOTE(  #include <stdio.h>                     )
  QUOTE(  int main() {                           )
  QUOTE(    printf("Greetings, earthlings.\n");  )
  QUOTE(    return 0;                            )
  QUOTE(  }                                      );
{code}

It works fine so long as there are no unmated parentheses on any given line.  

The vim highlighter doesn't really like curly braces within parens, but other
than that, the construct seems to work ok.


> Remove Perl dependency of METAQUOTE
> -----------------------------------
>
>                 Key: LUCY-71
>                 URL: https://issues.apache.org/jira/browse/LUCY-71
>             Project: Lucy
>          Issue Type: Improvement
>          Components: Charmonizer
>            Reporter: Nathan Kurz
>            Priority: Minor
>         Attachments: charm_and_harm_to_c_and_h.diff
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> Charmonizer currently uses a Perl script 'METAQUOTE' to preprocess its 
> '.charm' files into '.c' files and '.harm' files into '.h' files.   This 
> works, but requires a dependency on Perl that seems inappropriate for a C 
> language tool.
> The suggested alternatives were to use manual quoting or standard macros.  
> Manual quoting seemed error prone and cumbersome, so this patch proposes the 
> using the 'stringify' (#expr) function within standard C preprocessor macros.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to