[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

443.0. "PMAX vs VMS question" by HGOVC::KENBERKUN (Klaatu Barato Nikto) Mon Mar 20 1989 20:53

    I'm getting the following warnings when compiling my program on
    a PMAX.  I do not get the warnings on VAX C, VMS.  The program runs
    correctly in either case.  Can someone please suggest what I'm doing
    wrong and how to fix it.  I'm sure there must be a way to do this
    that doesn't generate warnings...
                                                
    ccom: Warning: yadman.c, line 317: struct/union or struct/union
    pointer required
            DwtGetNextSegment(&dwContext,&text.filename,&charset,
          --------------------------------------------^
    ccom: Warning: yadman.c, line 317: & before array or function: ignored
                 DwtGetNextSegment(&dwContext,&text.filename,&charset,
          ---------------------------------------------^
    
    The complete code fragment (complete fragment? :-)) is:
                              
   static void FileBoxproc(w, tag, list)
        Widget w;
        int *tag;
        DwtListBoxCallbackStruct *list;
    {
    
    DwtRendMask     rend;
    DwtCompStringContext    dwContext;
    char            *text;
    unsigned long   charset;
    int             dir;
    unsigned long   lang;
            printf("activate_FileBox has been called\n");
    
            /* Now read the value of the file name selected */
    
            /* extract the filename from the compound string */
    
            DwtInitGetSegment(&dwContext, list->item)
           DwtGetNextSegment(&dwContext,&text.filename,&charset,
                                                 &dir,&lang,&rend);
                                                 
      ...
    
    
    Thanks for any help or suggestions...
    
    Ken B.

T.RTitleUserPersonal
Name
DateLines
443.1Ultrix file alsoHGOVC::KENBERKUNKlaatu Barato NiktoTue Mar 21 1989 04:465
    I probably should have asked this one in the Ultrix file,  I'll
    cross post it there.
    
    ken b.

443.2AITG::DERAMODaniel V. {AITG,ZFC}:: D'EramoTue Mar 21 1989 08:1814
	The following two do not go together:

	    char            *text;

	and

	           DwtGetNextSegment(&dwContext,&text.filename,&charset,
                                                --------------

	You are taking [the address of] a structure reference off of
	a char * variable.

	Dan

443.3pcc is less forgiving than vccFLUME::dikeTue Mar 21 1989 08:3810
Listen to pcc.  It knows what it's talking about.  vcc will let a lot of highly
suspect contructs slip by that pcc won't.  You found one of them.  Others
include saying . when you mean -> and vice-versa and mixing of pointer types
are a couple more that come to mind.

In general, if your code compiles cleanly under pcc, it is portable and will
compile anywhere.  Compiling it under vcc tells you relatively little about
how it will port.
				Jeff

443.4use the compiler's optionsCASEE::LACROIXGone with the windTue Mar 21 1989 08:478
    Re .3:

    Or use VAX C with /STANDARD=PORTABLE. It's very unlikely that PCC will
    complain about something VAX C hasn't seen (with famous exceptions:
    function prototypes, etc...).

    Denis.

443.5ThanksHGOVC::KENBERKUNKlaatu Barato NiktoTue Mar 21 1989 20:125
    Thanks very much for all the replies.  Moving my little application
    to the MAX has been quite the lesson in portability.
                                                 
    Ken B.

443.6Uh...HGOVC::KENBERKUNKlaatu Barato NiktoWed Mar 22 1989 06:0517
    OK,  I never claimed to be a C guru...
    
    I'm still not sure how I should declare text and then how I should
    pass it to the routine.  I tried 
    
    char *text;  and passing it as text; &text; *text etc.
    (the old brute force approach...)  Some of these aren't accepted
    by the compiler and some just don't work.
    
    According to the manual it is expecting type **char and the routine
    will automatically allocate the space.
    
                                             
    Help.  Thanks again.
    
    ken_b_who_only_gets_to_write_code_late_at_night_please_have_mercy_on_me

443.7Some code...FLUME::dikeWed Mar 22 1989 08:3022
This code fragment is based on the documentation.  I haven't actually run it or
anything.

{
  char *text;

  DwtGetNextSegment(context, &text, ... rest of args...);
  ...
  do something with text
  ...

  XtFree(text);
}

text is declared as a character pointer, and occupies 4 bytes.  Its address
gets passed in to DwtGetNextSegment, which allocates memory for the string
and puts the address of that memory in text.  When you come back, text will
point at that memory, which contains the string that you asked for.

Hope this helps...
				Jeff

443.8ThanksHGOVC::KENBERKUNKlaatu Barato NiktoThu Mar 23 1989 05:187
    Well, I'm slow but I get there.. Yup, I left off the darn &.  Stuck
    it in and it works fine now!
    
    Thanks very much.
    
    Ken B.