T
Thomas Matthews
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 and 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
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 and 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