I am writing a C++ program for Linux. I use many low-level libraries such as XLib, FontConfig, Xft etc. They are all written in pure C, and in some pl ...
I am writing a C++ program for Linux. I use many low-level libraries such as XLib, FontConfig, Xft etc. They are all written in pure C, and in some pl ...
Const casting container value-types seems not possible. A comment in the other question suggests iterators as a solution, yet does not go into detail. ...
I have something like this: typedef struct { pthread_mutex_t mtx; /* Other stuff */ } some_struct_t; void some_func (some_struct_t *s) { ...
This may well have been asked in some other way before (I would be surprised if its not) but I am struggling to find it if it is. Given: #include &l ...
I am trying to understand why the following code compiles and runs fine. I would expect any assignment using data inside f not to compile with a gcc e ...
I can make pointer point to string literal, it will cast string literal to constant pointer, but reference to pointer can't assign string literal, for ...
Example: So the goal is to store a const pointer to some external object, not to store a copy of the external object's contents. Pass by const ...
The following C++ code does not compile because it's passing a non-const pointer to a find() function which expects a const pointer. #include <map ...
I'm trying to understand what is the common idiom (good practice) to provide creation/reclamation functions of a struct. Here is what I tried: I go ...
How can I declare a static const pointer to global volatile? I have this so far, but I'm not sure it's correct: Edit: I use it like this: For t ...
Is there any difference between: void (* const algorithm)(); and void const (* const algorithm)(); when dealing with const pointers to static meth ...
This code doesn't compile: However this one compiles perfectly: I understand that a pointer that is more CV-qualified at any level can point t ...
Normally, C file I/O is done using FILE* as this is what the standard library functions all take. In C, one can also have a const pointer, where the ...
I want to make a constant double pointer points to a constant pointer points to a constant double. I started to make it (of course I make a little sea ...
I am getting an error: error: invalid initialization of non-const reference of type 'std::string& {aka std::basic_string&}' from an rvalue of ...
The weird thing is this outputs: * For lookup fucntion: 0x9999999 0x1277777 some_string * For test code 0x9999999 0x1277777 0000000000000000000000 ...
I need a 2d array with fixed width and height that can only change the individual values stored in it. It is declared in a header and later initialize ...
As far as I know, const int * implies that I can change the pointer but not the data, int * const says that I can't change the pointer address but I c ...
I have this function signature: What's the point of the const keyword in this particular context? Even if ptr wasn't a const variable, I couldn't ...
This question is a bump of a question that had a comment here but was deleted as part of the bump. For those of you who can't see deleted posts, the ...