compile time error in defining function with unknown return value

25 views
Skip to first unread message

mayank gupta

unread,
Apr 21, 2012, 10:06:14 AM4/21/12
to clip...@googlegroups.com
I have added an external function written in C to CLIPS
its definition is
void findFromBSON(DATA_OBJECT_PTR returnValuePtr);

and added following to userfunctions.c 
66> extern void findFromBSON(DATA_OBJECT_PTR );
72> DefineFunction2( ...);

during compilation i am getting the following error
userfunctions.c: In function ‘UserFunctions’:
userfunctions.c:66: warning: parameter names (without types) in function declaration

Can you help me with what might have possibly gone wrong?
I have also added other functions, none of them which require returning unknown values using DATA_OBJECT_PTR, and those are working correctly.

Lode Hoste

unread,
Apr 22, 2012, 8:17:19 AM4/22/12
to clip...@googlegroups.com
I guess you lack the 'clipsEnv' parameter.
Try:

extern void findFromBSON(void *theEnv, DATA_OBJECT_PTR returnValuePtr);


Additional information might be helpful.

2012/4/21 mayank gupta <sharpsp...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "CLIPSESG" group.
> To post to this group, send email to CLIP...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/CLIPSESG?hl=en
>
> --> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--
> Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
> Click on "Edit my membership" link.
> Select the "No Email" radio button.
> Click the "Save these settings" button.
>
> --> IF YOU WANT TO UNSUBSCRIBE <--
> Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
> Sign in
> Click on "Edit my membership" link.
> Click the "Unsubscribe" button.
> Note: This appears to be the most reliable way to unsubscribe
>
> Alternately, send email to CLIPSESG-u...@googlegroups.com. You will
> receive an email which you must respond to as well to unsubscribe. Clicking
> the link mentioned in the unsubscribe reply does not appear to work
> reliably.

mayank gupta

unread,
Apr 22, 2012, 2:14:52 PM4/22/12
to clip...@googlegroups.com
Yes, I did try using
extern void findFromBSON(DATA_OBJECT_PTR returnValuePtr)
and it says error: expected ‘)’ before ‘returnValuePtr’
 
regarding Environment variable, should it be necessary for the function to be Environment specific? The other functions I have added do not require one.

Thanks

Lode Hoste

unread,
Apr 22, 2012, 6:54:40 PM4/22/12
to clip...@googlegroups.com
You forgot to #include "evaluatn.h" (which defines DATA_OBJECT_PTR).

With regard to the environment argument: yes, you need to define it
even though you won't use it.
CLIPS expects you to accept it. You should look into simple examples,
such as AbsFunction, IntegerFunction, etc.
I advice you to add it to your existing functions as well.

I have two related questions:
- How do you inspect the arguments functions without using the environment?
- And are you sure you don't know the return type of your
findFromBSON function? If it is an external pointer, you can define
(DefineFunction2) your function to return CLIPS type "a" which allows
you to easily return a void* to your data structure (without having to
manually set the DATA_OBJECT_PTR).

2012/4/22 mayank gupta <sharpsp...@gmail.com>:

mayank gupta

unread,
Apr 22, 2012, 11:51:54 PM4/22/12
to clip...@googlegroups.com
The error is during compilation of "userfunctions.c" . I will give it a try and tell you the results.

I had considered adding env argument but it wasn't on priority, and most of the examples in the Advanced programming guide do not use env argument. 

How do you inspect the arguments functions without using the environment? 
The functions mentioned in the Advanced programming guide are working. First use an RtnUnknown() call to get the argument in DATA_OBJECT then cast it to required type using DOTo...() functions.

And are you sure you don't know the return type of your findFromBSON function?
This actually is the result of a database query. So, I was trying to write a single function that would return int,string or other basic types from the result. I have added different functions to return int,strings etc but that's just too much of redundancy. A single function would reduce it. I guess I will give the other solution a try.

In the end, I'll try to write an application abstract for our use case.
Thanks
  
Reply all
Reply to author
Forward
0 new messages