814,998 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
0
answers
7
views
How does the c++ compiler goes about handling function overloading?
I’m building a compiler for a programming language I created, and would like to support function and operator overloading. I understand what overloading is from a user’s perspective but I’m trying to ...
0
votes
0
answers
16
views
Linker can't seem to find SDL2 (undefined reference from `ld` not `g++`)
I'm relatively new to C++ and I'm trying to compile a very simple example program which simply shows a black window for 3000 ms and then exits. It compiles fine with g++ -lSDL2 hellosdl.cpp but ld ...
0
votes
0
answers
40
views
Force narrowing conversion warning but avoid narrowing int->double conversion warning
Similar to the problem described here I need to create a template class which should provide the conversion constructor from Any type. The conversion constructor should spot the narrowing conversions.
...
-4
votes
0
answers
57
views
Bazel build fails when generating OpenVINO Test Drive Windows bindings (MSVC toolchain / DLL errors) [closed]
### Description
I am trying to contribute to the **OpenVINO Test Drive** repository (https://github.com/openvinotoolkit/openvino_testdrive) and set it up locally.
I followed the documentation — ...
0
votes
0
answers
85
views
gtest complie error: undefined reference to `__imp__Exit'
I encountered this error when trying to compile a Gtest application using MinGW on Windows:
[build] D:/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/...
0
votes
3
answers
190
views
How to check at compile-time if a = b (where a and b are arguments of type T&) is valid inside a template function?
I'm experimenting with a function template that performs assignment:
#include <vector>
#include <memory>
template<typename T>
void foo(T& a, const T& b) {
a = b;
}
int ...
Best practices
0
votes
12
replies
154
views
What is the most efficient way to implement branching with a large number of outcomes in C++?
I have a function I am trying to write in C++ that takes a char and executes a unique code segment based on the character passed. I am scaling this to take around 50 characters, so I'm not sure that a ...
2
votes
1
answer
132
views
std::copy_assignable_v not working for reference types, how to fix?
Consider the following code where I test whether a type is copy-assignable by using the std::is_copy_assignable_v type-trait:
#include <print>
#include <type_traits>
struct IntProxy
{
...
0
votes
1
answer
114
views
Why does my 2D Vector of C strings not output the element at the given index? [duplicate]
Technically its a vector<vector<vector<const char *>>> but I'm using it as a vector<vector<cstrings>>
I have been stuck at this issue for weeks and I do not understand it....
-1
votes
0
answers
82
views
Directx8 transparency issue when two objects overlap
Hello Im quite new with directx, I'm mostly using it because its the interface that its being used for an old game, for which im writing a sort of wipe screen function, so it all works fine up until i ...
0
votes
0
answers
56
views
FLTK/Wayland/X11 custom drawing in a pop-up window
This question relates to a long standing open source application that has an FLTK UI and uses Cairo for custom drawing in various places. With FLTK 1.4, there is now a hybrid Wayland/X11 backend. We ...
0
votes
1
answer
137
views
Function using std::any and void*
Given the below code (running at https://godbolt.org/z/rEK1MEMxf):
#include "catch2/catch_all.hpp"
#include <any>
#include <list>
#include <algorithm>
#include <memory&...
0
votes
1
answer
51
views
Does the linker option -Wl,-rpath-link=dir need to be given for all the necessary library dependencies search paths?
I have the following project structure, where libb.so depends on liba.so, libc.so depends on libb.so and libd.so depends on libc.so
abcd
├── a
│ ├── lib.cpp
│ ├── lib.o
│ └── liba.so
├── b
│ ├─...
8
votes
1
answer
196
views
Clang accepts designated initialization where GCC/MSVC reject — compiler bug or invalid C++?
Clang compiles the following C++20 code snippet, while at the same time it is rejected by both GCC and MSVC.
There are at least two options:
The code is illegal and Clang fails to report an ...
0
votes
0
answers
81
views
Measuring button thickness from side-view image using DIPlib in C++ (profile measurement)
I am working on a machine vision application in C++ and using the DIPlib library for image processing.
I have a side-view (profile) grayscale image of a button-like part placed on a flat surface.
My ...