My c code uses 'memset' and 'close'. And I have added:
#include <stdio.h>
#include <glib.h>
#include <stdlib.h>
But I still get these warnings:
main.c:259: warning: implicit declaration of function ‘memset’
main.c:259: warning: incompatible implicit declaration of built-in function ‘memset’
main.c:268: warning: implicit declaration of function ‘close’
main.c:259: warning: incompatible implicit declaration of built-in function ‘close’
Can you please tell me how can I resolve these warnings?
Thank you.
Try to add next define at start of your .c file:
#define _GNU_SOURCE
It helped me with pipe2 function.
memset
requires you to import the header string.h
file. So just add the following header
#include <string.h>
...
A good way to findout what header file you are missing:
man <section> <function call>
To find out the section use:
apropos <function call>
Example:
man 3 memset
man 2 send
Edit in response to James Morris:
Source: Wikipedia Man Page
Old question but I had similar issue and I solved it by adding
extern void* memset(void*, int, size_t);
or just
extern void* memset();
at the top of translation unit ( *.c file ).
You need:
#include <string.h> /* memset */
#include <unistd.h> /* close */
in your code.
References: POSIX for close
, the C standard for memset
.
Source: Stackoverflow.com