Re: const struct members




"Bill Pursell" <bill.pursell@xxxxxxxxx> wrote in message
news:1146542089.926612.309830@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Rod Pemberton wrote:
"Bill Pursell" <bill.pursell@xxxxxxxxx> wrote in message
news:1146511188.133768.226850@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Suppose I have a structure with many members, and I pass a pointer to
that structure to a function. I'd like the prototype of the function
to specify that it will only be changing certain members of the
function, but I have only the following horrific way to do that. Can
someone please suggest a better alternative?


Since modify_b can't modify 'a' and modify_a can't modify 'b', why do
you
need to protect the other structure elements? Is there a data
corruption
issue here?


There's no data corruption problem, I just observed that in many
instances I have data structures with several buffers getting passed
into functions, and the only manner by which I can tell which function
modifies which buffer is to inspect the function body/comments. I
could modify the protoypes to specify that the struct is constant, but
that of course gives no assurance on the contents of foo->a. I suppose
the only other solution is to define the structure as having const
members and making it difficult to assign/modify things. Something
like:



It seems that you are trying to create C features with may be available in
C++. I know very little about C++, but IIRC, you can implement data
protection due to the object oriented feature of binding code with data.
The code gets executed for each action on the data. Which means, you can
prevent variables from being multiply assigned, set, reset or whatever...
Perhaps you might look into using a small amount of C++.


Rod Pemberton


.



Relevant Pages

  • Re: Members WebPart
    ... Modify the Members Web Part ... and then click Modify My Web Part. ... In the Toolbar Type list, specify the kind of toolbar you want for the Web ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: Windows Version numbers for Windows 2008
    ... to specify the size of the structure. ... backwards compatibility among versions of Windows. ... Also, if I add extra members to the structure, like ... Pointer to an OSVERSIONINFO data structure that the function ...
    (microsoft.public.vb.winapi)
  • Re: Help using Dsget to list compuetrs in group
    ... Either by command line or in ADUC query tool. ... the members (unless you bind to each member in a script and check the ... You do need to specify the full Distinguished Name of the group. ... the computer object is already in the specified OU. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Help using Dsget to list compuetrs in group
    ... When you enumerate members of a group, there is no way tell the class of the ... need to specify the full Distinguished Name of the group. ... I do this so the program can tell if the computer object is ... Dim objRootDSE, strDNSDomain, adoCommand, adoConnection ...
    (microsoft.public.windows.server.active_directory)
  • Re: Removing members from multiple groups in a OU
    ... Const ADS_PROPERTY_CLEAR = 1 ... For Each objGroup In objOU ... But I need to remove all members not just one in diffrent groups under one ... ' Specify the Distinguished Name of the user. ...
    (microsoft.public.windows.server.scripting)