C Set/2

C Set/2

Post by Uma Arunkum » Fri, 21 Aug 1992 05:38:11



****************** C Set/2   QUESTION ************************
I am trying to compile a Microsoft C 6.0 C program
in C Set/2 version 1.00.

   The program compiles without errors in MSC 6.0.  But
   it is giving errors at one point.

 (i)  There is a structure like the one below in "prog1a.h":
   struct {
          short a;
          short b;
          short (* fun_name)();
   } command;

  (ii) There is an array of structures in "prog1.c"
       which has the above structure type.
       I am initializing the array of structures.
       commands cmd_array[] = {
                              {1,    2,   Test1}
                              {3,    4,   Test2}
   };

  (iii) The problem arises in initializing.  Test1 and Test2 are given
        prototypes in a file called "prog1b.h" as

        extern short Test1(short p, short q, short r);
        extern short Test2(short x, short y);

  (iv) When I compile giving the command
            icc /c /w3 /o+ prog1.c prog1a.h prog1b.h

       I get the following error messages:

       1. error EDC0227 : The return types of the functionm pointers are incompatible.
       2. informational EDC0140: Operand has type pointer to _Optlink function returning signed short integer.
       3. informational EDC0140: Operand has type _Optlink function returning signed short integer.

       WHAT DOES THIS MEAN?
       How should I initialize a table with function pointers?
       In MSC 6.0, the function name evaluates into pointer expression.
       How about C Set/2?
       What is wrong in the above code?

I WOULD HIGHLY APPRECIATE SOME HELP.

Thanks in advance.


uma.

 
 
 

C Set/2

Post by dav » Fri, 21 Aug 1992 22:43:25



Quote:> (restructured a bit -- dmm)

>   struct {
>          short a;
>          short b;
>          short (* fun_name)();
>   } command;

>   extern short Test1(short p, short q, short r);
>   extern short Test2(short x, short y);

>   commands cmd_array[] = {
>                              {1,    2,   Test1}
>                              {3,    4,   Test2}
>   };

>   icc /c /w3 /o+ prog1.c prog1a.h prog1b.h

>       1. error EDC0227 : The return types of the functionm pointers are incompatible.
>       2. informational EDC0140: Operand has type pointer to _Optlink function returning signed short integer.
>       3. informational EDC0140: Operand has type _Optlink function returning signed short integer.

First of all, the error message is lying to you.  It's not the return
types of the function pointers which are incompatible -- it's the
parameter lists.  Your example can be chopped down to:

  int f(short);
  int (*fp)();

  fp = f;

For two function pointers to be compatible, their parameters lists must
be compatible.  If one of the parameter lists is empty and one isn't, all
the parameters in the non-empty list must be wide types (ie, not char,
short, or float).  All the*details are in section 3.5.4.3 of the
ANSI C Standard, but the upshot is that a function with a short parameter
is not compatible with a function pointer with no parameters.

We are easing up on this restriction in our next release (for the benefit
of people like you, whose code suddenly stops working), but in the mean
time, you can get around this problem by sticking in explicit casts on
the assignments:

  typedef short (* fptype)();

  typedef struct {
         short a;
         short b;
         fptype fun_name;
  } command;

  extern short Test1(short p, short q, short r);
  extern short Test2(short x, short y);

  command cmd_array[] = {
                             {1,    2,   (fptype)Test1},
                             {3,    4,   (fptype)Test2}
  };

dave

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

 C Set/2 Development, IBM Canada Lab, 844 Don Mills Rd, Toronto, Ontario
            "If you've got a blacklist, I want to be on it"

 
 
 

1. "C Set++" vs. "C Set++ FirstStep" Difference ???

Subj: "C Set++" vs. "C Set++ FirstStep"  Difference ?

IBM-Denmark is selling "C Set++" for $ 760 and
"C Set++ FirstStep" for $ 170.  I am not sure I need
"KASE:set", "Workframe/2 2.1 and "C++ Execution Trace Analysis"
so I am considering buying the cheap version.

My questions:
     Can I make PM programs ?
     Can I draw a simple x,y-graph in a window ?

using the "C Set++ First Step".

No one at IBM-Denmark could answer :-(    
I was connected to several people who all blamed the switchboard
and gave me a new number to call !  I like OS/2, I like
CorelDraw/2, I would like to continue to use and promote OS/2, but ...

Best wishes and thanks ...

Finn Jensen, Aalborg, Denmark.

2. How do I programmatically create a Web Folder shortcut

3. problems with C Set+;integrating C Set and EMX(GNU)

4. Visual Thought 1.3: UNIX & Windows diagramming for software design

5. Unable to set object error when install C Set++ Tools

6. 1996 courses on Soft Computing

7. KASE:Set (C Set++'s GUI Builder)

8. (probably naive) question about S5, Compact Flash, & backups...

9. C Set++ vs C Set++ FirstStep (vs Watcom)

10. IBM C++ Set/2 versus old C Set/2 Question

11. How Can you set Default DOS setting

12. Is it possible to set file type of all files in a folder without opening individual setting pages ?

13. Setting for DOS program started from windows? How to set them?