Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:49:21+00:00 2026-06-17T18:49:21+00:00

I would like something like the following gperf input file: %{ #include <keywords.h> //

  • 0

I would like something like the following gperf input file:

%{
#include <keywords.h>
// the contents of which contain
// #define KEYWORD1_MACRO "keyword1"
// #define KEYWORD2_MACRO "keyword2"
%}
%%
KEYWORD1_MACRO
KEYWORD2_MACRO
%%

Unfortunately, gperf will interpret those as the stings “KEYWORD1_MACRO”, etc.

The reason for this is that I have a protocol spec provided by another party as a header file, containing such #defines. So I don’t have control over how they are defined, and I’d rather not have to write another preprocessing tool to #include the header and output the expansion of the macros as quoted strings, only then for use as a gperf input file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:49:23+00:00Added an answer on June 17, 2026 at 6:49 pm

    I made the following experiment which uses gcc -E to deal with those #includes.

    keywords.h:

    #define KEYWORD1_MACRO "keyword1"
    #define KEYWORD2_MACRO "keyword2"
    

    test.c:

    %{
    #include "keywords.h"
    %}
    %%
    KEYWORD1_MACRO
    KEYWORD2_MACRO
    %%
    

    Command: gcc -E -o test.out.txt test.c.
    Then, the content in test.out.txt:

    # 1 "test.c"
    # 1 "<built-in>"
    # 1 "<command line>"
    # 1 "test.c"
    %{
    # 1 "keywords.h" 1
    # 3 "test.c" 2
    %}
    %%
    "keyword1"
    "keyword2"
    %%
    

    The #includes are handled automatically. You can then do some text processing and feed into gperf.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file template.txt which contains the following: Hello ${something} I would like
I would like to do something like the following: if params[:entry].include? (http || www
I would do something like the following in a Mako file: %for operation in
I want something like the following but would like it to be reusable for
I would like to do something like the following with spark. <viewdata model=IList[[string]] />
I would like to use something like the following: SELECT city FROM cities WHERE
Would it be possible to do something like the following in c#? Basically TParent
I would like to do something like the following: class Foo(object): def __init__(self): self.member
I would like to do something like the following UPDATE table SET column =
What I would like to do is something like the following: #!/bin/sh EMAIL=-e 's/SOMETHING//g'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.