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 6641729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:50:43+00:00 2026-05-25T23:50:43+00:00

In my makefile I have the following target, which compiles text/HTML resources into unsigned

  • 0

In my makefile I have the following target, which “compiles” text/HTML resources into unsigned char arrays using xxd -i.

I wrap the result in an anonymous namespace and header guards for multiple-inclusion safety both inside and between translation units.

templates.h:
    @echo "#ifndef TEMPLATES_H" > templates.h
    @echo "#define TEMPLATES_H" >> templates.h
    @echo "// Auto-generated file! Do not modify!" >> templates.h
    @echo "// NB: arrays are not null-terminated" >> templates.h
    @echo "// (anonymous namespace used to force internal linkage)" >> templates.h
    @echo "namespace {" >> templates.h
    @echo "namespace templates {" >> templates.h
    @cd templates;\
    for i in * ;\
    do \
        echo "Compiling $$i...";\
        xxd -i $$i >> ../templates.h;\
    done;\
    cd ..
    @echo "}" >> templates.h
    @echo "}" >> templates.h
    @echo "#endif" >> templates.h

The output, if I had just one such resource, looks like this (actual content redacted):

#ifndef TEMPLATES_H
#define TEMPLATES_H
// Auto-generated file! Do not modify!
// NB: arrays are not null-terminated
// (anonymous namespace used to force internal linkage)
namespace {
namespace templates {
unsigned char alert_email_finished_events_html[] = {
  0x3c, 0x74, 0x61, 0x62, 0x6c, 0x0d, 0x0a
};
unsigned int alert_email_finished_events_html_len = 7;
}
}
#endif

What would be the best way to programmaticaly apply GCC’s __attribute__ ((unused)) to these character arrays? I don’t want GCC warning about any resources that I end up not using in any given TU, but I also don’t want to turn “unused variable” warnings off altogether.

  • 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-05-25T23:50:43+00:00Added an answer on May 25, 2026 at 11:50 pm

    I think a quick sed should work, given that the output of xxd -i is very regular:

    xxd -i $$i | sed -e 's/ =/ __attribute__((unused)) =/' >> ../templates.h
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following PHONY target in Makefile install: echo /usr/bin/shelldecrypt must be writable
In a makefile, I have the following line: helper.cpp: dtds.h Which ensures that helper.cpp
I'm using GNU Make 3.81, and I have the following rule in my Makefile:
I have the following makefile which is a slight modification on others that I
I have a makefile with something like the following targets: install: do a whole
I have the following makefile for my project, and I'd like to configure it
I have used -Wall -Werror in my Makefile but I want to disable following
gcc 4.4.4 I have the following Makefile OBJECT_FILES = brd.o logger.o test_brd.o CFLAGS =
I have the following makefile: OUTPUTDIR = build all: v12target v13target v12target: INTDIR =
I started a simple makefile for my project (MS-windows target, MinGW) with the following

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.