I’m new to objective c & c. I’m trying to use this random generator c library in an objective c program. My understanding is that objective c is a strict superset of c so this should be possible.
My code compiles and runs but I get a lot of warnings.
- warning: implicit declaration of function ‘mt_seed32’
- warning: implicit declaration of function ‘mt_lrand’
- warning: Semantic Issue: Implicit declaration of function ‘mt_seed32’ is invalid in C99
- warning: Semantic Issue: Implicit declaration of function ‘mt_lrand’ is invalid in C99
- warning: Semantic Issue: Incompatible integer to pointer conversion initializing
uint32_t *(akaunsigned int *) with an expression of typeint
I have not imported the C header file to the objective c class – it just finds it. If I import it I get duplicate method errors.
C library header file:
extern void mt_seed32(uint32_t seed);
extern uint32_t mt_lrand(void);
Code to call it: [I’ve tried calling it with [self method()] but that crashes
mt_seed32(3);
uint32_t *i = mt_lrand();
Can anyone tell me how too get rid of these warnings?
The last compiler error happens because
mt_lrand();returns an int, not a pointer to an int. Therefore, the last line should beAll the other errors are due to the fact that you did not
#includethe library header. Could you please post the errors that occur when you do include the library header?