815,035 questions
2
votes
3
answers
101
views
C++ std::span overload resolution
I want to pass a C-style array to a function taking a std::span, but overload resolution chooses to convert the array to bool instead. Is this behavior required by the standard, or is it a compiler ...
2
votes
2
answers
145
views
How to avoid implicit conversion in C++ concepts?
Is there a way to prevent implicit conversions happening in concepts? For example, this example compiles with GCC and clang when I actually want it to give an error that the char constructor is ...
1
vote
2
answers
93
views
Detect existence of name in at least one base class
This code (reduced from the Chromium codebase) is accepted by Clang but rejected by GCC:
template<class T> concept Concept = requires {typename T::marker;};
#define INJECT_MARKER using marker = ...
0
votes
0
answers
95
views
File IO in C++ (or C) without the overhead of copying between two buffers with Linux Systems [closed]
I'm interested to understand more about performing file IO operations with systems programming languages in a way which does not use both a kernel space buffer and a user space buffer.
Specifically I ...
2
votes
2
answers
79
views
Rust and C++ FFI: orchestrating destructors/drops of struct fields
Because of some FFI code interacting with C++ I need precise manual control on when the Drop::drop() method of types is called w.r.t. those of fields.
To be more precise:
When a C++ struct is ...
0
votes
1
answer
34
views
Why is this GTK+ C++ program not showing a button with a black rectangular box boundary as expected?
I have the following HDSentinel.cpp program designed to run under the GTK+ library environment. I had a simple Hello.cpp program that I tried to adapt so that the "Hello World" button would ...
1
vote
2
answers
107
views
Issue with multithreaded/concurrent use of ReadFile() Windows API
I'm currently working on a project that requires a multi-threaded approach. This project is currently platform specific, i.e. Windows.
This is how my read code looks like:
#pragma once
#include <...
Tooling
0
votes
1
replies
45
views
emacs with c++-mode and indentation
I have problems with the indentation where I am using keywords like export in combination with namespace.
export namespace foo::bar {
// indentation is wrong
}
when the export keyword is one line ...
2
votes
1
answer
105
views
Why is std::filesystem::current_path() not able to get current path? [closed]
I'm using VS Code with CMake Tools extension on Ubuntu.
This C++ program produces the following output when run with "CMake: Debug" (which I select using the Command Palette):
#include <...
2
votes
1
answer
98
views
Does an explicit instantiation declaration allow an explicit template specialization to be only declared in a separate translation unit?
Short version: Does an explicit instantiation declaration guarantee that a visible template definition is never used (unless an explicit instantiation definition is also encountered), and therefore ...
3
votes
1
answer
95
views
I want to use a different compiler but when i close vscode or refresh it goes back to the same old compiler settings
i am having trouble updating c_cpp_properties.json:
{
"version": 4,
"configurations": [
{
"name": "windows-clang-x64",
"includePath&...
4
votes
1
answer
116
views
External linkage objects with constructors/destructors in shared libraries
While answering this question I decided to check myself and did a little experiment. There are three files:
// moo.h
#ifndef MOO_H
#define MOO_H
#include <iostream>
struct Moo
{
Moo() {
...
Advice
1
vote
17
replies
195
views
Surprising behaviour of using static_cast on struct with bit fields
The following code compiles on std >= C++20 but fails to compile on std < C++20. This holds for msvc, gcc and clang.
#include <cstdio>
int main()
{
struct byte
{
unsigned ...
1
vote
2
answers
363
views
What impediments are there to inclusion of the Networking TS in the C++26 standard?
As C++26 standard's timeline is getting near, I want to know:
What is(are) the reason for no built in support of networking by the C++ standard. That is, what exactly are the problems that lead to ...
0
votes
2
answers
91
views
Why Isn't the Dynamic Link Library Using Its Statically Linked Functions? [duplicate]
a (main calls c and d)
|
+-----------+-----------+
| |
libc.so (c calls b) libd.so (d calls b)
| |
| |
...