Thread: Unable to explain these errors.

  1. #1
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342

    Unable to explain these errors.

    Here is a part of the code that is creating some problems.
    Code:
     
     1 typedef int (mpich_peruse_callback_f)(peruse_event_h event_h,
      2               MPI_Aint unique_id, void * spec, void * param);
      3
      4
      5 struct mpich_peruse_handle_t
      6 {
      7     int handle;
      8     int ref_count;
      9     int active;                     /**< Whether this handle has been activated */
     10     int event;                      /**< Event being watched */
     11     int type;                       /**< Object-type this event is registered on */
     12     MPID_Comm *comm;                 /**< Corresponding communicicator */
     13     mpich_peruse_callback_f *fn;     /**< Callback function specified by user */
     14     void *param;                     /**< Parameters being passed to callback */
     15 };
     16
     17 typedef struct mpich_peruse_handle_t  mpich_peruse_handle_t;
     18
     19
     20 void PERUSE_TRACE_COMM_EVENT(int event, MPID_Request *req, int op)
     21 {
     22     if( NULL != req->comm->c_peruse_handles )
     23     {
     24         mpich_peruse_handle_t * _ptr = req->comm->c_peruse_handles[(event)];
     25         printf(" ref_count = %d\n", _ptr->ref_count);
     26         if (NULL != _ptr && _ptr->active) {
     27             peruse_comm_spec_t _comm_spec;
     28             _comm_spec.comm      = req->comm;
     29             _comm_spec.operation = (op);
     30             _ptr->fn(_ptr, (MPI_Aint)(req), &_comm_spec, _ptr->param);
     31         }
     32     }
     33 return;
     34 }
    And these are the error messages being displayed :
    Code:
    Line no 13 : error: expected specifier-qualifier-list before ‘mpich_peruse_callback_f’
     In function ‘PERUSE_TRACE_COMM_EVENT’:
    Line no 30 : error: ‘mpich_peruse_handle_t’ has no member named ‘fn’
    Line no 30 :  error: ‘mpich_peruse_handle_t’ has no member named ‘param’
    I am totally vexed by these errors as they seem to be pretty much correct. 'mpich_peruse_callback_f' has been defined before the structure 'struct mpich_peruse_handle_t' is defined. And the structure clearly contain the members 'fn' and 'param'.

    I tried compiling using the -E option, I did see anything suspicious in these lines. Am I missing something that is obvious here?

    Thanks.
    In the middle of difficulty, lies opportunity

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    don't you miss * in your function pointer declaration?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'm not entirely sure, but I believe you want the * for the function pointer in the typedef, and not in the struct.

    Code:
    typedef int (mpich_peruse_callback_f *)(peruse_event_h event_h,
                   MPI_Aint unique_id, void * spec, void * param);
    ...
        mpich_peruse_callback_f fn;     /**< Callback function specified by user */
    This may not help at all, but it is what looks unusual to me in the code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can someone help me with these errors please code included
    By geekrockergal in forum C Programming
    Replies: 7
    Last Post: 02-10-2009, 02:20 PM
  2. Replies: 6
    Last Post: 08-23-2008, 01:16 PM
  3. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM