Posted February 21, 2019
low rated
Just one question that I've come up with, about a situation that I personally haven't encountered, but which seems realistic.
Suppose that we're developing software for an embedded system, and we have a C++ compiler that, while, functional, is a bit outdated; in particular, it does not support constexpr. (Let's just say it supports the C++98 standard, if you want a specific version.) For the software being developed, it has been determined that we need to pre-compute some values at compile time. (Doing this at run-time is not feasible, as the target CPU is rather weak and computing the values at run-time would take too long.) So, looking at the situation, we have found two reasonable options. Which of these options would be a better choice?
1. Use template metaprogramming to compute the values at compile-time. This, while clever, can be a pain for C++ programmers who aren't used to it to understand, and it is a bit ugly.
2. Write a program on the host system that, when executed, would generate a C++ source file containing the computed values, and work it into our build system. This means we can use any language available on the host, but it does make the build a bit more complicated.
So, which would be the better option in this situation?
Edit: Fix a missing negative.
Suppose that we're developing software for an embedded system, and we have a C++ compiler that, while, functional, is a bit outdated; in particular, it does not support constexpr. (Let's just say it supports the C++98 standard, if you want a specific version.) For the software being developed, it has been determined that we need to pre-compute some values at compile time. (Doing this at run-time is not feasible, as the target CPU is rather weak and computing the values at run-time would take too long.) So, looking at the situation, we have found two reasonable options. Which of these options would be a better choice?
1. Use template metaprogramming to compute the values at compile-time. This, while clever, can be a pain for C++ programmers who aren't used to it to understand, and it is a bit ugly.
2. Write a program on the host system that, when executed, would generate a C++ source file containing the computed values, and work it into our build system. This means we can use any language available on the host, but it does make the build a bit more complicated.
So, which would be the better option in this situation?
Edit: Fix a missing negative.
Post edited February 22, 2019 by dtgreene