473,468 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

const structure & member pointers

Hi,

Given a structure of pointers:
struct Example_Struct
{
unsigned char * ptr_buffer;
unsigned int * ptr_numbers;
};

And a function that will accept the structure:
void My_Function(struct Example_Struct * es)
{
es->ptr_buffer[0] = 0;
es->ptr_numbers[2] = 7;
return;
}

Does the above function modify the {instance of
the} structure?

Can the pointer to the structure be passed as
pointing to const data?

----------- Snip here before replying -------
Background
-----------
In my program I have a structure containing
pointers to messages, message data, and a
response buffer. The content of the message,
data and response buffer will be changed; but
their locations will not be. In other words,
I am changing the data the pointers point to
but not the value of the pointers.

PC-Lint says I can declare the pointer to
the structure as a pointer to const data.

------------
Crossposting
------------
This is crossposted to news:comp.lang.c,
news:comp.lang.c++ and news:alt.comp.learn.lang.c-c++
since it deals with a fundamental issue shared
by both the C and C++ language and may be of
interest to readers in all groups.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #1
19 6795

"Thomas Matthews" <Th****************************@sbcglobal.net> wrote in
message news:2k***************@newssvr15.news.prodigy.com. ..
Hi,

Given a structure of pointers:
struct Example_Struct
{
unsigned char * ptr_buffer;
unsigned int * ptr_numbers;
};

And a function that will accept the structure:
void My_Function(struct Example_Struct * es)
{
es->ptr_buffer[0] = 0;
es->ptr_numbers[2] = 7;
return;
}

Does the above function modify the {instance of
the} structure?

Can the pointer to the structure be passed as
pointing to const data?


Yes, but only because the struct contains pointers. If the struct contained
arrays the answer is no.

This part is C++ specific. This is a good example of why public data members
are almost always a bad idea. If the ptr_buffer and ptr_numbers members
where not public then you could control access to them and by including or
omitting const from the member functions that access ptr_buffer and
ptr_numbers you could control what consistuted a modification of the
Example_Struct struct. With public data you have no such control.

john
Jul 22 '05 #2

"John Harrison" <jo*************@hotmail.com> wrote in message
news:c5************@ID-196037.news.uni-berlin.de...

"Thomas Matthews" <Th****************************@sbcglobal.net> wrote in
message news:2k***************@newssvr15.news.prodigy.com. ..
Hi,

Given a structure of pointers:
struct Example_Struct
{
unsigned char * ptr_buffer;
unsigned int * ptr_numbers;
};

And a function that will accept the structure:
void My_Function(struct Example_Struct * es)
There's no reason for the word "struct" in the parameter list above. (BTW,
is it legal to have it there?)
{
es->ptr_buffer[0] = 0;
es->ptr_numbers[2] = 7;
return;
}

Does the above function modify the {instance of
the} structure?

Can the pointer to the structure be passed as
pointing to const data?
Yes, but only because the struct contains pointers. If the struct

contained arrays the answer is no.


Why would it not be the case if the members were arrays instead of pointers?
The function takes a pointer (by value), so it points to the same struct
object (not a copy of it) as the one wherever it is called from, right?
Since it is the same struct and not a copy, the members of that struct are
the same members, regardless of whether they're arrays, strings, pointers,
or whatever. Am I missing something here?

-Howard

Jul 22 '05 #3
Howard wrote:
"Thomas Matthews" <Th****************************@sbcglobal.net> wrote in
message news:2k***************@newssvr15.news.prodigy.com. ..
And a function that will accept the structure:
void My_Function(struct Example_Struct * es)

There's no reason for the word "struct" in the parameter list above. (BTW,
is it legal to have it there?)


In C it is "illegal" to not have it there. So yes, there is plenty
of reason to have it there. Why this is crossposted so widely I
don't know though.

--
Thomas.

Jul 22 '05 #4
Thomas Matthews wrote:
Hi,

Given a structure of pointers:
struct Example_Struct
{
unsigned char * ptr_buffer;
unsigned int * ptr_numbers;
};

And a function that will accept the structure:
void My_Function(struct Example_Struct * es)
{
es->ptr_buffer[0] = 0;
es->ptr_numbers[2] = 7;
return;
}

Does the above function modify the {instance of
the} structure?
No, what the pointers point to is not part of the structure unless
they are pointing to a field in the structure. (That would be very
nice ;)

Can the pointer to the structure be passed as
pointing to const data?


Yep.

--
Thomas.
Jul 22 '05 #5
"Howard" <al*****@hotmail.com> wrote in message
news:c5********@dispatch.concentric.net
"John Harrison" <jo*************@hotmail.com> wrote in message
news:c5************@ID-196037.news.uni-berlin.de...

"Thomas Matthews" <Th****************************@sbcglobal.net>
wrote in message news:2k***************@newssvr15.news.prodigy.com. ..
Hi,

Given a structure of pointers:
struct Example_Struct
{
unsigned char * ptr_buffer;
unsigned int * ptr_numbers;
};

And a function that will accept the structure:
void My_Function(struct Example_Struct * es)
There's no reason for the word "struct" in the parameter list above.
(BTW, is it legal to have it there?)


Yes.
{
es->ptr_buffer[0] = 0;
es->ptr_numbers[2] = 7;
return;
}

Does the above function modify the {instance of
the} structure?

Can the pointer to the structure be passed as
pointing to const data?


Yes, but only because the struct contains pointers. If the struct
contained arrays the answer is no.


Why would it not be the case if the members were arrays instead of
pointers? The function takes a pointer (by value), so it points to
the same struct object (not a copy of it) as the one wherever it is
called from, right? Since it is the same struct and not a copy, the
members of that struct are the same members, regardless of whether
they're arrays, strings, pointers, or whatever. Am I missing
something here?

If the pointer to the struct points to something const, then the struct must
not be changed. If the struct contains pointers, then that means the
pointers cannot be changed. The data pointed to by the pointers is *not*
part of the struct, so it can be changed.

With arrays, by contrast, the array elements are part of the struct and
hence they cannot be changed.

--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
Jul 22 '05 #6
>
And a function that will accept the structure:
void My_Function(struct Example_Struct * es)

There's no reason for the word "struct" in the parameter list above. (BTW, is it legal to have it there?)


In C it is "illegal" to not have it there. So yes, there is plenty
of reason to have it there. Why this is crossposted so widely I
don't know though.

--
Thomas.


Oh, I didn't notice the corss-posting. I just hit Reply to Group, assuming
it was for the C++ language group, since that's the only one I read. Sorry.

-Howard


Jul 22 '05 #7

"John Carson" <do***********@datafast.net.au> wrote in message
news:40******@usenet.per.paradox.net.au...
"Howard" <al*****@hotmail.com> wrote in message
news:c5********@dispatch.concentric.net
"John Harrison" <jo*************@hotmail.com> wrote in message
news:c5************@ID-196037.news.uni-berlin.de...
{
es->ptr_buffer[0] = 0;
es->ptr_numbers[2] = 7;
return;
}

Does the above function modify the {instance of
the} structure?

Can the pointer to the structure be passed as
pointing to const data?

Yes, but only because the struct contains pointers. If the struct
contained arrays the answer is no.

Why would it not be the case if the members were arrays instead of
pointers? The function takes a pointer (by value), so it points to
the same struct object (not a copy of it) as the one wherever it is
called from, right? Since it is the same struct and not a copy, the
members of that struct are the same members, regardless of whether
they're arrays, strings, pointers, or whatever. Am I missing
something here?

If the pointer to the struct points to something const, then the struct

must not be changed. If the struct contains pointers, then that means the
pointers cannot be changed. The data pointed to by the pointers is *not*
part of the struct, so it can be changed.

With arrays, by contrast, the array elements are part of the struct and
hence they cannot be changed.


That still does not make sense to me, and I've tested the idea and found
that's not the case at all.

I'm not sure what it is that you're saying might be const here...the struct
whose address is stored in the pointer? Or the pointer? The parameter to
the function does not specify a const pointer of a pointer to const struct,
so you'll get a compiler error if you try to pass either of those. I can
pass it a pointer to a const struct by casting away the constness when
assigning the address to the pointer, but that's not something you would
want to do. (And I don't see anything at all about const anything in the
original post.)

But in any case, I tried with both arrays and with pointers, and it most
certainly *does* modify the member, just as I expected. I also tried it
with a pointer to a const object, by casting away the constness when
assigning the address. Same result. I assign 'Z' and 999 respectively to
the members (both pointer and array) in my constructor, but then set those
to 'A' and 1 in my function, and I get 'A' and 1 as the results. Here's my
code:

#include <iostream>

struct Example
{
unsigned char* pC;
unsigned int* pI;

unsigned char C[1];
unsigned int I[1];

Example();
~Example();
};

Example::Example()
{
pC = new unsigned char[1];
pI = new unsigned int[1];

pC[0] = 'Z';
pI[0] = 999;
C[0] = 'Z';
I[0] = 999;
}

Example::~Example()
{
delete pC;
delete pI;
}

void MyExampleFunction( Example* pE )
{
pE->pC[0] = 'A';
pE->pI[0] = 1;
pE->C[0] = 'A';
pE->I[0] = 1;
}

int main()
{
using namespace std;

Example E;
MyExampleFunction(&E);
cout << "E.pC[0] " << E.pC[0] << endl;
cout << "E.pI[0] " << E.pI[0] << endl;
cout << "E.C[0] " << E.C[0] << endl;
cout << "E.I[0] " << E.I[0] << endl;

const Example E2;
Example* pE = (Example*)&E2;
MyExampleFunction(pE);
cout << "pE->pC[0] " << pE->pC[0] << endl;
cout << "pE->pI[0] " << pE->pI[0] << endl;
cout << "pE->C[0] " << pE->C[0] << endl;
cout << "pE->I[0] " << pE->I[0] << endl;

return 0;;
}
-Howard



Jul 22 '05 #8

"Howard" <al*****@hotmail.com> wrote in message
news:c5********@dispatch.concentric.net...
whose address is stored in the pointer? Or the pointer? The parameter to
the function does not specify a const pointer of a pointer to const struct, so you'll get a compiler error if you try to pass either of those. I can


Should read "...does not specify a const pointer OR a pointer to a const
struct..."

-Howard
Jul 22 '05 #9

"Howard" <al*****@hotmail.com> wrote in message
news:c5********@dispatch.concentric.net...
(And I don't see anything at all about const anything in the
original post.)


Sorry, didn't scroll down far enough for the const part of the discussion.
D'oh!

-Howard
Jul 22 '05 #10

"Howard" <al*****@hotmail.com> wrote in message
news:c5********@dispatch.concentric.net...

"John Carson" <do***********@datafast.net.au> wrote in message
news:40******@usenet.per.paradox.net.au...
"Howard" <al*****@hotmail.com> wrote in message
news:c5********@dispatch.concentric.net
"John Harrison" <jo*************@hotmail.com> wrote in message
news:c5************@ID-196037.news.uni-berlin.de...
>
>> {
>> es->ptr_buffer[0] = 0;
>> es->ptr_numbers[2] = 7;
>> return;
>> }
>>
>> Does the above function modify the {instance of
>> the} structure?
>>
>> Can the pointer to the structure be passed as
>> pointing to const data?
>
> Yes, but only because the struct contains pointers. If the struct
> contained arrays the answer is no.
>

Why would it not be the case if the members were arrays instead of
pointers? The function takes a pointer (by value), so it points to
the same struct object (not a copy of it) as the one wherever it is
called from, right? Since it is the same struct and not a copy, the
members of that struct are the same members, regardless of whether
they're arrays, strings, pointers, or whatever. Am I missing
something here?

If the pointer to the struct points to something const, then the struct

must
not be changed. If the struct contains pointers, then that means the
pointers cannot be changed. The data pointed to by the pointers is *not*
part of the struct, so it can be changed.

With arrays, by contrast, the array elements are part of the struct and
hence they cannot be changed.


That still does not make sense to me, and I've tested the idea and found
that's not the case at all.

I'm not sure what it is that you're saying might be const here...the

struct whose address is stored in the pointer? Or the pointer? The parameter to
the function does not specify a const pointer of a pointer to const struct, so you'll get a compiler error if you try to pass either of those. I can
pass it a pointer to a const struct by casting away the constness when
assigning the address to the pointer, but that's not something you would
want to do. (And I don't see anything at all about const anything in the
original post.)

But in any case, I tried with both arrays and with pointers, and it most
certainly *does* modify the member, just as I expected. I also tried it
with a pointer to a const object, by casting away the constness when
assigning the address. Same result. I assign 'Z' and 999 respectively to
the members (both pointer and array) in my constructor, but then set those
to 'A' and 1 in my function, and I get 'A' and 1 as the results. Here's my code:

#include <iostream>

struct Example
{
unsigned char* pC;
unsigned int* pI;

unsigned char C[1];
unsigned int I[1];

Example();
~Example();
};

Example::Example()
{
pC = new unsigned char[1];
pI = new unsigned int[1];

pC[0] = 'Z';
pI[0] = 999;
C[0] = 'Z';
I[0] = 999;
}

Example::~Example()
{
delete pC;
delete pI;
}

void MyExampleFunction( Example* pE )
{
pE->pC[0] = 'A';
pE->pI[0] = 1;
pE->C[0] = 'A';
pE->I[0] = 1;
}

int main()
{
using namespace std;

Example E;
MyExampleFunction(&E);
cout << "E.pC[0] " << E.pC[0] << endl;
cout << "E.pI[0] " << E.pI[0] << endl;
cout << "E.C[0] " << E.C[0] << endl;
cout << "E.I[0] " << E.I[0] << endl;

const Example E2;
Example* pE = (Example*)&E2;
MyExampleFunction(pE);
cout << "pE->pC[0] " << pE->pC[0] << endl;
cout << "pE->pI[0] " << pE->pI[0] << endl;
cout << "pE->C[0] " << pE->C[0] << endl;
cout << "pE->I[0] " << pE->I[0] << endl;

return 0;;
}
-Howard


You are missing the point.

This compiles

struct X
{
char* ptr;
};

int f(const X* x_ptr)
{
*x_ptr->ptr = 'a';
}

This does not

struct X
{
char array[1];
};

int f(const X* x_ptr)
{
*x_ptr->array = 'a';
}

That's the distinction I was making.

And the reasons are as John Carson said, the array is part of the X object,
whatever is pointed to by the ptr member of the X object is not part of the
X object.

john
Jul 22 '05 #11
Ok, I see. I thought you were responding to the first question (does the
function modify the instance), not the second one (about passing a pointer
to const data). My mistake.

-Howard
Jul 22 '05 #12

"Howard" <al*****@hotmail.com> wrote in message
news:c5********@dispatch.concentric.net...
Ok, I see. I thought you were responding to the first question (does the
function modify the instance), not the second one (about passing a pointer
to const data). My mistake.


I took the first question to be a badly phrased version of the second
question, possibly my mistake.

john
Jul 22 '05 #13
Beware, heavy cross-posting. Beware furthermore: "const" has a
*different* meaning in C than in C++. In particular, C "const"
variables are actually variables, not constants:

const int seven = 7;
int i;
...
switch (i) {
case 3: ... code for i==3 ...
case seven: ... /* this line is an error in C, but OK in C++ */
}

In C "const" *always* means "read-only variable", much like
"extern const" in C++.

Summary of issue: Suppose "p" is a pointer to a const-qualified
structure or class variable, i.e., "const struct S *p" rather than
unqualified "struct S *p". What are the implications of an assignment
of the form "p->field[index] = new_value"? The answer depends on
whether the "field" member is a pointer or an array.
"John Carson" <do***********@datafast.net.au> wrote in message
news:40******@usenet.per.paradox.net.au...
... If the struct contains pointers, then that means the
pointers cannot be changed. The data pointed to by the pointers is *not*
part of the struct, so it can be changed.

With arrays, by contrast, the array elements are part of the struct and
hence they cannot be changed.

In article <news:c5********@dispatch.concentric.net>
Howard <al*****@hotmail.com> writes:That still does not make sense to me ...
Think of it as an "ownership issue". If I buy an array and lend it
to you, so that you point to it, *my* rules apply to that array,
even though you have borrowed it.

On the other hand, if *you* buy an array, *your* rules apply to it.

The const-ness of the array members depends on who "owns" them.
If the array is part of "struct S" (as a member named "field"), it
is the "struct S" that owns them; if the member named "field" is
just a pointer, it points to an array owned elsewhere, and the
const-ness of the array elements cannot be determined from the
const-ness of "*p".
and I've tested the idea and found that's not the case at all.


I fear your test merely shows that the effect of undefined behavior
is often "hey, it works for me". :-) Alas, this is the sort of
thing that leads people to think that:

int i = 0;
...
f(i++, i++, i++); /* DANGER */

is well-defined and (depending on their system) always passes {2,
1, 0} or always passes {0, 1, 2} to f(). (Many systems actually
deliver one or the other fairly consistently.)

I snipped the original C++ example code, which was rather fatally
flawed for showing the problem (classes with constructors generally
need to be run-time modifiable even when const-qualified; you have
to stick to PODs *and* use static instances of each object).

Try this example instead (compile-able as both C *and* C++). First
the output:

% ln t.c++ t.c

[same program!]

% gcc -O -o t t.c -ansi -pedantic -Wall
% ./t
this was compiled with a C compiler
before:
P.field[0] = a
A.field[0] = a
modify P
P.field[0] = b
modify A
Segmentation fault (core dumped)
[C version crashes]

% gcc -O -o t t.c++ -Wall
% ./t
this was compiled with a C++ compiler
before:
P.field[0] = a
A.field[0] = a
modify P
P.field[0] = b
modify A
Segmentation fault (core dumped)
[C++ version crashes]

And the code:

#include <stdio.h>

struct ptr {
char *field;
};

struct arr {
char field[1];
};

void wr_ptr(const struct ptr *p) {
p->field[0] = 'b';
}

void wr_arr(struct arr *p) { /* cannot use "const" here */
p->field[0] = 'b';
}

static char buf[1] = { 'a' };
static const struct ptr P = { buf };
static const struct arr A = { { 'a' } };

struct trick2 { char x[1]; };

int main(void)
{
struct scopetrick { struct trick2 { char x[2]; } x; };

printf("this was compiled with a %s compiler\n",
sizeof ((struct trick2 *)0)->x == 2 ? "C" : "C++");

printf("before:\n");
printf(" P.field[0] = %c\n", P.field[0]);
printf(" A.field[0] = %c\n", A.field[0]);
fflush(stdout);

printf("modify P\n");
fflush(stdout);
wr_ptr(&P);
printf(" P.field[0] = %c\n", P.field[0]);
fflush(stdout);

printf("modify A\n");
fflush(stdout);
wr_arr((struct arr *)&A); /* cast required here */
printf(" A.field[0] = %c\n", A.field[0]);
fflush(stdout);

return 0;
}
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Jul 22 '05 #14
Howard wrote:
<Th****************************@sbcglobal.net> wrote in

Given a structure of pointers:
struct Example_Struct
{
unsigned char * ptr_buffer;
unsigned int * ptr_numbers;
};

And a function that will accept the structure:
void My_Function(struct Example_Struct * es)


There's no reason for the word "struct" in the parameter list
above. (BTW, is it legal to have it there?)


Not only is it legal, but it is essential. Bear in mind this is
c.l.c.

It would be well to never reply to things cross-posted to c.l.c
and c.l.c++, apart from telling the OP to make up his mind.

--
fix (vb.): 1. to paper over, obscure, hide from public view; 2.
to work around, in a way that produces unintended consequences
that are worse than the original problem. Usage: "Windows ME
fixes many of the shortcomings of Windows 98 SE". - Hutchison
Jul 22 '05 #15
The whole thing on my part was a misunderstanding of what was being
responded to. See my other post in this thread in response to John
Harrison. (Also, I was unaware of the cross-posting, and was thinking
purely in C++.) I understand perfectly the implications of using const, but
my example was not related to that, because of my misunderstanding of what
was being discussed. Sorry for the confusion.
-Howard
Jul 22 '05 #16

"CBFalconer" <cb********@yahoo.com> wrote in message
news:40***************@yahoo.com...

It would be well to never reply to things cross-posted to c.l.c
and c.l.c++, apart from telling the OP to make up his mind.


I had no intention of cross-posting...I simply hit the "Reply to Group"
button as always, not even noticing the cross-posting going on. Sorry.

-Howard

Jul 22 '05 #17
"Thomas Matthews" <Th****************************@sbcglobal.net> wrote in
message news:2k***************@newssvr15.news.prodigy.com. ..
Hi,

Given a structure of pointers:
struct Example_Struct
{
unsigned char * ptr_buffer;
unsigned int * ptr_numbers;
};

And a function that will accept the structure:
void My_Function(struct Example_Struct * es)
{
es->ptr_buffer[0] = 0;
es->ptr_numbers[2] = 7;
return;
}

Does the above function modify the {instance of
the} structure?
The members of Example_Struct are non-const pointers, so in the case of a
const Example_Struct, as with all included objects you *can not* change
their value (in this case the addresses they have stored) but you can change
the values of the pointed third objects.

Can the pointer to the structure be passed as
pointing to const data?

I suppose you mean const Example_Struct *es, yes.


Ioannis Vranos

Jul 22 '05 #18
"Howard" <al*****@hotmail.com> wrote in message
news:c5********@dispatch.concentric.net...
And a function that will accept the structure:
void My_Function(struct Example_Struct * es)

There's no reason for the word "struct" in the parameter list above.

(BTW, is it legal to have it there?)

It is legal and optional (but required in C).

Why would it not be the case if the members were arrays instead of pointers? The function takes a pointer (by value), so it points to the same struct
object (not a copy of it) as the one wherever it is called from, right?
Since it is the same struct and not a copy, the members of that struct are
the same members, regardless of whether they're arrays, strings, pointers,
or whatever. Am I missing something here?

You can't change the contents of a const struct, but you can change the
value of third non-const objects pointed by non-const-for-modification
pointer variables inside that const struct.
int main()
{

struct whatever
{
char *p;
};

char array[5];

const whatever s={array};

// invalid sice s is const
// s.p=0;

// Valid since the object pointed is non-const
// and p is not const char *
s.p[2]='H';
}


Ioannis Vranos

Jul 22 '05 #19
On 15 Apr 2004 13:40:14 EDT, "Howard" <al*****@hotmail.com> wrote:

"John Harrison" <jo*************@hotmail.com> wrote in message
news:c5************@ID-196037.news.uni-berlin.de...
struct Example_Struct <contents snipped>
void My_Function(struct Example_Struct * es)


There's no reason for the word "struct" in the parameter list above. (BTW,
is it legal to have it there?)

As already noted it is certainly required in C -- unless you also
typedef struct X X, which can be combined with the struct declaration,
and is also legal though redundant in C++.

In C++ it is always legal, and is necessary if you have also declared
Example_Struct as an ordinary identifier (variable or enumerator) in
the same or closer scope (or a different typedef in closer scope),
which is a very bad idea but legal even though it is a very bad idea.
Did I mention it's a bad idea? :-)

- David.Thompson1 at worldnet.att.net
Jul 22 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Corno | last post by:
Hi all, There's probably a good reason why a const object can call non const functions of the objects where it's member pointers point to. I just don't see it. For me, that makes the the const...
2
by: joe | last post by:
hi, after reading some articles and faq, i want to clarify myself what's correct(conform to standard) and what's not? or what should be correct but it isn't simply because compilers don't...
4
by: Mahesh Tomar | last post by:
Dear Readers, I am porting my existing C code to C++. In my existing code there are numerous functions that has been defined with CONST qualifier. For eg. foo(const DATA_TYPE *x); DATA_TYPE is...
25
by: Thomas Matthews | last post by:
Hi, Given a structure of pointers: struct Example_Struct { unsigned char * ptr_buffer; unsigned int * ptr_numbers; }; And a function that will accept the structure:
2
by: Pavel | last post by:
I am writing software for an embedded application and here is the question. GCC would emit data declared like const char text = "abc"; to .rodata (i.e. "read only data") section. I can put this...
11
by: x-pander | last post by:
given the code: <file: c.c> typedef int quad_t; void w0(int *r, const quad_t *p) { *r = (*p); }
15
by: JiÅ™Ć­ PaleĨek | last post by:
Hello, I know the rules for const handling in C++, but I'd like to ask what is the "right" way to use them, eg. when is it appropriate to make a member function const? This came across this...
0
by: d3x0xr | last post by:
Heh, spelled out in black and white even :) Const is useles... do NOT follow the path of considering any data consatant, because in time, you will have references to it that C does not handle,...
4
by: developereo | last post by:
Hi folks, Can anybody shed some light on this problem? class Interface { public: Interface() { ...} virtual ~Interface() { ...} virtual method() = 0; };
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.