Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
Filter by Employee ID
Score of 8
3 answers
322 views

Consider the following two lines of code: const char c = 'a'; const string s = "" + c; The 2nd line is giving me error CS0133: The expression being assigned to 's' must be constant. ...
Best practices
1 vote
10 replies
282 views

I learned about inline variables in C++17, but I still have some confusion about them. When should I use extern variables versus inline variables for sharing constant global variables across multiple ...
Score of -3
3 answers
196 views

A few years ago I wrote some Perl code using JSON. It still worked in SLES15 SP6, but in SLES15 SP7 I get an error like this: Modification of a read-only value attempted at (eval 73)[/usr/lib/perl5/...
Score of 11
2 answers
1277 views

If I have a function template returning const-qualified type (with a trivial body for example): const auto f(auto) { return 1; } and I want to get a pointer on a particular instance of the function ...
Score of 4
2 answers
174 views

I have a program that I would like to build in Visual Studio 2026, but struggle with the errors appearing. One simplified piece of code is as follows: void f(const void*) {} int main() { ...
Score of 1
4 answers
206 views

I'm new to pointers and trying to wrap my head around how casting and dereferencing should function in comparator functions that qsort takes. My understanding is these always have the signature int ...
Score of 1
2 answers
193 views

For context, I have a function to print some text, which naturally takes in a ⁨const char *const *⁩ as one of its arguments (meaning the provided text will not be modified in any way by the function). ...
Best practices
1 vote
11 replies
6k views

I'm hesitating whether the Logger Write method should be marked as const: class Logger { public: // Write log message to the terminal void Write(const string& msg) const; ... }; In this ...
Score of 14
2 answers
2299 views

struct foo { const int bar; }; struct foo { const int *bar; } Do the 2 const qualifiers have any role?
Score of 0
1 answer
156 views

In a script I'm using constants (use constant ...) to allow re-use ion actual regular expressions, using the pattern from https://stackoverflow.com/a/69379743/6607497. However when using a {...} ...
Best practices
0 votes
3 replies
57 views

Let's say my View has a bunch of sub-views, controlled by switches. struct MyView: View { var body: some View { if A { AView() } else { BView() } } } But A is a constant ...
Best practices
1 vote
5 replies
197 views

Defining a string and converting it to bytes at runtime is one thing, but I would want to have a constant array of bytes defined at design time and then pupulate it with a mix of bytes and strings. ...
Score of 4
2 answers
167 views

For background, I am working to create a version of minesweeper that runs in the terminal to become more familiar with coding bigger projects in c. I am coding in VScode, to run on a Linux server (...
Score of 2
1 answer
151 views

In the C standard (at least, I'm looking at draft C23 WG14/N3088), section 6.7.3 Type Qualifiers states: 7 If an attempt is made to modify an object defined with a const-qualified type through the ...
Score of 6
2 answers
363 views

When I have some const members variables in my class, I would like to know how to respect core guideline C.12 to keep a default copy-assignment operator. C.12: Don’t make data members const or ...

15 30 50 per page
1
2 3 4 5
696