814,934 questions
Advice
0
votes
7
replies
60
views
C++ std::string short string optimization detection
If you have a string
std::string data("This is a string long enough so that it is not a short string");
Then you have a view onto that string:
std::string_view dataView(std::begin(...
0
votes
0
answers
18
views
Linkage of Win32 api and custom GCC build (StrawberryPerl)
I try to build some source code containig Win32 API code with GCC 8.3.0 (i686-posix-dwarf) that comes with Strawberry Perl Portable package. It easily builds code, but struggles when it comes to ...
-2
votes
0
answers
37
views
Why excatly are std::cin/std::cout slower than scanf/printf? [closed]
I understand that std::cin/std::cout are generally slower than scanf/printf, and that's primarily due to synchronization with C’s standard streams. However, all explanations I saw just say that and ...
0
votes
1
answer
33
views
snd_pcm_readi returns an empty array
I want to transmit audio from the microphone to the headphones (something like an echo). However, when calling snd_pcm_readi, my array remains empty.
PCM parametrs for capture audio(In real code, ...
-3
votes
0
answers
41
views
How do real-world C++ developers think about object design, aggregation/composition, and templates in large embedded systems? [closed]
I have a solid understanding of C++ syntax and OOP fundamentals — classes, inheritance, polymorphism, encapsulation, etc. However, I’m struggling to understand how these concepts come together in real-...
1
vote
0
answers
44
views
What makes QGuiApplication construction hang in this case?
Here's a piece of Qt code:
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QGuiApplication app2(argc, argv);
The first constructor call returns, the second does not.
I ...
4
votes
1
answer
98
views
Is this const_cast in the context of type-erasure undefined behavior?
While looking at this example: https://github.com/PacktPublishing/Hands-On-Design-Patterns-with-CPP-Second-Edition/blob/main/Chapter06/09_function.C
which is an implementation of std::function with ...
2
votes
1
answer
94
views
Why is Eigen C++ int matrix multiplication 10x slower than float multiplication (even slower than naive n^3 algorithm)
I'm testing int matrix multiplication, but I found that it's extremely slow everywhere (python numpy using BLAS backend is also just as slow). Int matmul being slower than float matmul is ...
2
votes
1
answer
54
views
Why is attribute noinline ignored by gcc-15.1.0 in this example?
Looking at this benchmark about a custom std::function implementation: https://github.com/PacktPublishing/Hands-On-Design-Patterns-with-CPP-Second-Edition/blob/main/Chapter06/09_function.C
I tried to ...
0
votes
0
answers
72
views
Exceedingly excessive amount of blank lines before and after the information in my output file?
For some reason, whenever I output my formatted information my output txt file there is a ridiculous amount of blank lines before(after header) and after said information. The goal of my program is to ...
Advice
0
votes
5
replies
103
views
How to make a GUI library in C++
I have wanted to make a GUI library so that I can use it in my own video game that I am making and maybe in the future have it be used for other things like software. I wanted to ask where to start ...
5
votes
0
answers
54
views
How to make Doxygen show warnings on undocumented code?
Environment
Windows 11
Doxygen 1.15.0
Command: doxygen Doxyfile
Goal
Fail the build when anything is undocumented. I expect warnings (and with WARN_AS_ERROR=YES, errors) for undocumented functions, ...
6
votes
1
answer
220
views
Is there a way to explicitly instantiate many template classes all with the same set of parameters?
I've got many templated classes which all need to be explicitly instantiated on the same set of parameters e.g.
template class A<double, size_t>;
template class A<double, unsigned int>;
...
0
votes
1
answer
88
views
How to call inline functions by using dl library?
I have to use dl library for calling libapt-pkg functions. The method I need to call is pkgCacheFile::GetPkgCache() that is declared as inline. The problem is that dlsym returns error while trying to ...
14
votes
2
answers
305
views
Parsing of small floats with std::istream
I have a program that reads the coordinates of some points from a text file using std::istringstream, and then it verifies the correctness of parsing by calling stream's operator bool().
In general it ...