Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation (if possible) on how to integrate CTP C++ code into reStructuredText documents compiled by Sphinx #24

Open
anadon opened this issue Nov 10, 2022 · 2 comments
Labels
question Further information is requested

Comments

@anadon
Copy link

anadon commented Nov 10, 2022

I think I briefly saw somewhere use of this project as a way to include limited C++ snippets that are "run" at text generation time without the need for some meta-level build system nonsense. How does one do this?

I also can't get the following to work:
compile-time-printer -- g++ -std=c++20 -I ../include/ -fsyntax-only -fpermissive examples/compile_time_examples.cpp
for https://gitlab.com/anadon/prime_generator_header/-/blob/master/examples/compile_time_examples.cpp

@Viatorus
Copy link
Owner

Viatorus commented Nov 10, 2022

Hi @anadon,

I am not aware of it. I cannot really help you with that. You have to somehow compile your code-snippet and integrate the output later inside the documention.

To your second question:
You must evaluate your code at compile-time via constexpr/consteval.

Doing this is also bad-practice: Now ctp::printf and the C function printf are in the same scope.

using namespace std;
using ctp::printf;
using madlib::primes;
using madlib::prime_generator;

@Viatorus Viatorus added the question Further information is requested label Nov 10, 2022
@anadon
Copy link
Author

anadon commented Nov 10, 2022

I think I could work on it if the installation steps worked as described, where after installed via pip the header becomes available when run as below. As for the using statements above, it is for clarity to new users; the choice of using order is intentional to replace the standard printf().

anadon@Poymon:~/Documents/code/prime_generator_header$ compile-time-printer --  g++ -std=c++20 -I include/ -fsyntax-only examples/compile_time_examples.cpp
No CTP output found.
examples/compile_time_examples.cpp:4:10: fatal error: ctp/ctp.hpp: No such file or directory
    4 | #include <ctp/ctp.hpp>
      |          ^~~~~~~~~~~~~
compilation terminated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants