Can anyone explain this C code to me?

This is a discussion on Can anyone explain this C code to me? within the modula forums in Programming Languages category; I'm trying to work with the Motif libraries in XDS, I have lots of questions regarding some of the C code I come across but I muddle through, however, this one has me stumped: It relates to extracting the filename selected with the FileSelectionBox XmFileSelectionBoxCallbackStruct *cbs = (XmFileSectionBoxCallbackStruc *) call_data; Can someone explain to me what is going on there? I know that call_data is an XtPointer, XmFileSelectionBoxCallbackStruct is a RECORD and *cbs is a dereferenced pointer, I think. but what is that * just before the ) in the second line? I'm guessing it has something to do with ...

Go Back   Application Development Forum > Programming Languages > modula

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-03-2008, 05:54 PM
Terry Ross
Guest
 
Default Can anyone explain this C code to me?

I'm trying to work with the Motif libraries in XDS, I have lots of
questions regarding some of the C code I come across but I muddle through,
however, this one has me stumped:

It relates to extracting the filename selected with the FileSelectionBox

XmFileSelectionBoxCallbackStruct *cbs =
(XmFileSectionBoxCallbackStruc *) call_data;


Can someone explain to me what is going on there? I know that
call_data is an XtPointer,
XmFileSelectionBoxCallbackStruct is a RECORD and *cbs is a dereferenced
pointer, I think.

but what is that * just before the ) in the second line? I'm guessing it
has something to do with dereferencing something, but I have no idea how
to convert it to Modula-2.

Thanks for any input.

Terry



--
Terry "qnr" Ross | http://www.aliboom.com
1024D/E5796C4D | Key BE84 EC1D FC94 D97B 9063 AD15 0F38 193A E579 6C4D
Source Mage GNU/Linux http://www.sourcemage.org
Reply With Quote
  #2  
Old 09-03-2008, 06:05 PM
Manuel Collado
Guest
 
Default Re: Can anyone explain this C code to me?

Terry Ross escribió:
> I'm trying to work with the Motif libraries in XDS, I have lots of
> questions regarding some of the C code I come across but I muddle through,
> however, this one has me stumped:
>
> It relates to extracting the filename selected with the FileSelectionBox
>
> XmFileSelectionBoxCallbackStruct *cbs =
> (XmFileSectionBoxCallbackStruc *) call_data;
>
>
> Can someone explain to me what is going on there? I know that
> call_data is an XtPointer,
> XmFileSelectionBoxCallbackStruct is a RECORD and *cbs is a dereferenced
> pointer, I think.
>
> but what is that * just before the ) in the second line?


A typecast. See:
http://www.cprogramming.com/referenc...ng/cstyle.html

> ... I'm guessing it
> has something to do with dereferencing something, but I have no idea how
> to convert it to Modula-2.


Perhaps the CAST function, available on ISO Modula-2, could help.

--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
Reply With Quote
  #3  
Old 09-03-2008, 06:12 PM
Terry Ross
Guest
 
Default Re: Can anyone explain this C code to me?

On Thu, 04 Sep 2008 00:05:34 +0200, Manuel Collado wrote:

> Terry Ross escribió:

[...snipped...]
>
> A typecast. See:
> http://www.cprogramming.com/referenc...ng/cstyle.html
>
> > ... I'm guessing it
>> has something to do with dereferencing something, but I have no idea
>> how to convert it to Modula-2.

>
> Perhaps the CAST function, available on ISO Modula-2, could help.


Ah, thank you Manuel, that helps, I'll experiment a bit with this.

Terry



--
Terry "qnr" Ross | http://www.aliboom.com
1024D/E5796C4D | Key BE84 EC1D FC94 D97B 9063 AD15 0F38 193A E579 6C4D
Source Mage GNU/Linux http://www.sourcemage.org
Reply With Quote
  #4  
Old 09-24-2008, 05:01 AM
Frank Schoonjans
Guest
 
Default Re: Can anyone explain this C code to me?

XmFileSelectionBoxCallbackStruct * means POINTER TO
XmFileSelectionBoxCallbackStruct

In the second line: (XmFileSectionBoxCallbackStruc *) call_data;
means convert call_data to a POINTER TO XmFileSelectionBoxCallbackStruct

So to convert to Modula-2:

TYPE PtrType = POINTER TO XmFileSelectionBoxCallbackStruct;

VAR cbs : PtrType;

cbs := CAST(PtrType,call_data);

Frank.

"Terry Ross" <tross04401@spamcop.net> wrote in message
news:XN-dnXQPmv_mmiLVnZ2dnUVZ_g2dnZ2d@giganews.com...
> I'm trying to work with the Motif libraries in XDS, I have lots of
> questions regarding some of the C code I come across but I muddle through,
> however, this one has me stumped:
>
> It relates to extracting the filename selected with the FileSelectionBox
>
> XmFileSelectionBoxCallbackStruct *cbs =
> (XmFileSectionBoxCallbackStruc *) call_data;
>
>
> Can someone explain to me what is going on there? I know that
> call_data is an XtPointer,
> XmFileSelectionBoxCallbackStruct is a RECORD and *cbs is a dereferenced
> pointer, I think.
>
> but what is that * just before the ) in the second line? I'm guessing it
> has something to do with dereferencing something, but I have no idea how
> to convert it to Modula-2.
>
> Thanks for any input.
>
> Terry
>
>
>
> --
> Terry "qnr" Ross | http://www.aliboom.com
> 1024D/E5796C4D | Key BE84 EC1D FC94 D97B 9063 AD15 0F38 193A E579 6C4D
> Source Mage GNU/Linux http://www.sourcemage.org



Reply With Quote
  #5  
Old 09-25-2008, 03:47 PM
qnr
Guest
 
Default Re: Can anyone explain this C code to me?

On Sep 24, 4:01*am, "Frank Schoonjans" <Frank.Schoonj...@ugent.dot.be>
wrote:
> XmFileSelectionBoxCallbackStruct * means POINTER TO
> XmFileSelectionBoxCallbackStruct
>
> In the second line: (XmFileSectionBoxCallbackStruc *) call_data;
> means convert call_data to a POINTER TO XmFileSelectionBoxCallbackStruct
>
> So to convert to Modula-2:
>
> TYPE PtrType = POINTER TO XmFileSelectionBoxCallbackStruct;
>
> VAR cbs : PtrType;
>
> cbs := CAST(PtrType,call_data);
>
> Frank.
>
> "Terry Ross" <tross04...@spamcop.net> wrote in message
>
> news:XN-dnXQPmv_mmiLVnZ2dnUVZ_g2dnZ2d@giganews.com...
>

[...snipped...]
Thank you Frank, I appreciate your help.

Terry
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:19 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.