function pointer help needed (again)

Bob Calbridge bobc at attctc.Dallas.TX.US
Tue Jul 18 11:19:58 AEST 1989


Well, here I am again.  Stuck in that twilight zone where I know just enough
to get me into trouble.  What seems obvious isn't.  I should mention that I am
using Turbo C for this.

Here's the problem.  I'm attempting to use the windowing functions of a library
called CXL to design a utility program.  The function I'm having problems with
are is called "wmenuitem".  Its declaration is:


int      _Cdecl wmenuitem(int wrow,int wcol,char *str,int schar,int tagid,
                          int fmask,void (_Cdecl *select)(void),
                          unsigned hotkey,int help);

Following is an extract of the components of the function:


    ------------------------------------------------------------------------

    NAME
        wmenuitem

    DESCRIPTION
        Defines a menu item.  This is one of the 4 functions that are
        required to process a menu.

    SYNOPSIS
        #include "cxlwin.h"
        int wmenuitem(int wrow,int wcol,char *str,int schar,int tagid,
                      int fmask,void (*select)(void),unsigned hotkey,
                      int help);

    INPUTS
        wrow   - window row
        wcol   - window column
        str    - address of menu item string
        schar  - quick selection character
        tagid  - unique tag identifier of this particular menu item.  This
                 is the value that wmenuget() returns upon its selection.
        fmask  - feature mask.  Allows you to define one or more additional
                 features for this menu item.  Valid features are:
                     M_HASPD - has a pull-down menu attached
                     M_NOSEL - menu item is not selectable
                     M_CLOSE - close this menu when item is selected
                     M_CLALL - close all menus when item is selected
                 More than one feature can be specified by using the C
                 bitwise OR operator '|'.  For example, if this item has a
                 pull-down menu attached and it is not selectable, you would
                 specify (M_HASPD|M_NOSEL). Specify 0 if you don't want to
                 define an fmask for this item.
        select - address of the function to call upon selection of this menu
                 item.  Specify NULL if you don't want to define a select
                 function.
        hotkey - keycode of the key, which when pressed, will select this
                 menu item's function from anywhere within the menu
                 structure.  This allows the user to call this menu item's
                 select function even if not currently processing its menu.
                 See Appendix B for a list of keycodes that you can use.
                 Specify 0 if you don't want to define a hotkey.
        help   - help category number to be associated with this item.
                 Specify 0 is you don't want to define a help category for
                 this item.

    RETURN VALUE
        W_NOERROR  - no error
        W_NOMNUBEG - no begin of menu specified.  See wmenubeg().
        W_ALLOCERR - memory allocation error


    EXAMPLE
        wmenuitem(0,0,"Load   F3",'L',1,M_CLOSE,load_file,0x3d00,0);

    ------------------------------------------------------------------------

Now, here's a piece from my program:


wmenubeg (27,9,53,20,5,0,_BLUE|WHITE,NULL);
	wmenuitem (1,2,"Build a configuration",'B',1,0,build_config(),0,0);
	wmenuitem (2,2,"Change a configuration",'C',2,0,change_config(),0,0);
	wmenuitem (3,2,"Convert a file",'F',3,0,conv_file(),0,0);
wmenuend (1, M_VERT|M_PD|M_SAVE, 0, 0, _BLUE+WHITE, RED, LGREY, YELLOW);
wmenuget ();


There are several problems that arise from my code depending on what tact I
take.  In the form above the compiler reports "Non-portable pointer conversion".
This is more of a warning than an error.  The cursor positions itself after the
final '0' in the parameters.

If, per the example, I leave the '()'s off the function in the select
parameter it says "Undefined symbol 'build_config'".  In this case the cursor
is positioned following the function name "build_config".

In other instances, which I have been unable to reproduce after having fiddled
with the code, produce error messages that specify that the error was produced
in "select" and another message that demands a memory address.

The structure of the code above is intended to produce a bar menu which acts
upon the menuitems when selected.  In the code segment above, with the
non-portable pointer conversion, the first menu item is initiated without
producing a window.

Can anyone tell me (1) in what way my code differs from the example, that I
need to put the "()"s after the function name and (2) what the problem is
with the non-portable pointer conversion, does it cause the code to run 
improperly and should I worry about it.

Sorry for the band width but I'm still learning.

Thanks.
Bob
the 
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=             I know it's petty..........                                     =
-                  But I have to justify my salary!                           -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



More information about the Comp.lang.c mailing list