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

  • SEARCH
  • Home
  • 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 9022179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:26:25+00:00 2026-06-16T05:26:25+00:00

I have a file module.hpp struct ModuleBase { virtual void run() = 0; };

  • 0

I have a file module.hpp

struct ModuleBase {
    virtual void run() = 0;
};

and a main.cpp program

int main() {
    cout << ...?...; // here should go the contents of module.hpp
}

What can I put at ...?... to let the contents of the header file printed here?

A basic idea would be

int main() {
    static const string content = R"(
#include <module.hpp>
)";
    cout << content;
}

but multi-line-strings are only available in C++11, and #include does not work inside multi-line strings (which is good)?

If there is a non-portable way for the gcc… that would be a start.

Clarification (update): The substitution should be done at compile time.

  • 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-16T05:26:26+00:00Added an answer on June 16, 2026 at 5:26 am

    The only real solution I know is to write a small program which
    converts a file into a C++ definition of a string variable
    containing it. This is fairly simple to write: output a simple
    header along the lines of:

    char const variableName[] =
    

    Then copy each line of the file, wrapping it in "...\n", and
    escaping any characters necessary. (If you can be sure of
    C++11, then you might be able to do something with R"...", but
    I’ve no experience with this.)

    [update: refering to the original question with a typo in it]:
    Your solution should not work; if it does, it is an error in
    the compiler. According to §2.2, tokenization occurs before
    the execution of preprocessing directives. So when the
    execution of preprocessing directives occurs, you have a string
    literal, and not a # preprocessing token. (Compiler errors
    are to be expected when using C++11 features. There’s not been
    enough time yet for the implementers to get all of the bugs
    out.)

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

Sidebar

Related Questions

I have a main.cpp like so: #include <boost/python.hpp> const char* greeting() { return Hello
I have a ruby file as follows: module Example class Myclass def t_st Hello
I have a python file testHTTPAuth.py which uses module deliciousapi and is kept in
I am using drupal 7 with apachesolr module. I have an external file field
i have a parent pom file that include 3 module... and there is difference
I have a file uploader module. The UI is created using simple HTML and
I have a file that I want to read in using the File::Slurp module
I have several file extensions, like .module , that I would like to be
If I have a JMS module defined in a file (my-module-jms.xml) copied from one
I have a folder named Lib and I am using the File::Find module to

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.