Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8706371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:35:52+00:00 2026-06-13T03:35:52+00:00

I just had this error: main.c:8: error: implicit declaration of function ‘malloc’ main.c:8: error:

  • 0

I just had this error:

main.c:8: error: implicit declaration of function ‘malloc’
main.c:8: error: incompatible implicit declaration of built-in function ‘malloc’
main.c:14: error: implicit declaration of function ‘printf’
main.c:14: error: incompatible implicit declaration of built-in function ‘printf’

As I had these errors before, I knew that I forgot to add

#include <stdlib.h>
#include <stdio.h>

and a google search would have revealed the missing headers quite soon.

But what would I do, if I had no internet? How would I find the missing header files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:35:53+00:00Added an answer on June 13, 2026 at 3:35 am

    apropos and man

    apropos [text] can search through man files, e.g.:

    $ apropos malloc
    __malloc_hook (3)    - malloc debugging variables
    malloc (3)           - Allocate and free dynamic memory
    malloc_hook (3)      - malloc debugging variables
    mtrace (1)           - Interpret output from MALLOC_TRACE
    mtrace (3)           - malloc debugging
    muntrace (3)         - malloc debugging
    XtMalloc (3)         - memory management functions
    

    Then you can take a look at the man page:

    $ man malloc
    
    NAME
           calloc, malloc, free, realloc - Allocate and free dynamic memory
    
    SYNOPSIS
           #include <stdlib.h>
    
           void *calloc(size_t nmemb, size_t size);
           void *malloc(size_t size);
           void free(void *ptr);
           void *realloc(void *ptr, size_t size);
    
    DESCRIPTION
           calloc()  allocates memory for an array of nmemb elements of size bytes
           each and returns a pointer to the allocated memory.  The memory is  set
    

    Which reveals that #include <stdlib.h> is missing.

    find and grep

    If apropos does not work, like for the following example, you can use find and grep to search through all source files:

    //#include "stdint.h"
    #include <stdio.h>
    
    main() {
        int8_t   *xy = (int8_t*) 1;
        printf("%p\n", xy);
    }
    
    test.c: In function ‘main’:
    test.c:4: error: ‘int8_t’ undeclared (first use in this function)
    test.c:4: error: (Each undeclared identifier is reported only once
    test.c:4: error: for each function it appears in.)
    test.c:4: error: ‘xy’ undeclared (first use in this function)
    test.c:4: error: expected expression before ‘)’ token
    

    The solution:

    moose@pc07:/usr/include$ find *.h | xargs grep "int8_t"
    db.h:   u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
    db.h:   u_int8_t *bp;           /* Allocated read buffer. */
    db.h:   u_int8_t            /* Unique file ID. */
    db.h:   int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
    db.h:   int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
    db.h:   int   (*prepare) __P((DB_TXN *, u_int8_t *));
    db.h:   u_int8_t gid[DB_GID_SIZE];
    db.h:   u_int8_t  gid[DB_GID_SIZE]; /* Global transaction ID */
    db.h:   u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */
    db.h:   (pointer = (u_int8_t *)(dbt)->data +                \
    db.h:       retdata = (u_int8_t *)(dbt)->data + *__p--;     \
    db.h:       if (retdlen == 0 && retdata == (u_int8_t *)(dbt)->data) \
    db.h:       retkey = (u_int8_t *)(dbt)->data + *__p--;      \
    db.h:       retdata = (u_int8_t *)(dbt)->data + *__p--;     \
    db.h:       retdata = (u_int8_t *)(dbt)->data + *__p--;     \
    db.h:       pointer = (u_int8_t *)(dbt)->data +         \
    db.h:       u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
    db.h:       if ((u_int8_t *)(dbt)->data + __off + (writedlen) > \
    db.h:           (u_int8_t *)(__p - 2))              \
    db.h:           writedata = (u_int8_t *)(dbt)->data + __off;    \
    db.h:       u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
    db.h:       if ((u_int8_t *)(dbt)->data + __off + (writeklen) + \
    db.h:           (writedlen) > (u_int8_t *)(__p - 4)) {      \
    db.h:           writekey = (u_int8_t *)(dbt)->data + __off; \
    db.h:           writedata = (u_int8_t *)(dbt)->data + __off;    \
    db.h:       pointer = (u_int8_t *)(dbt)->data +         \
    db.h:       u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
    db.h:       if (((u_int8_t *)(dbt)->data + __off) + (writedlen) >   \
    db.h:           (u_int8_t *)(__p - 3))              \
    db.h:           writedata = (u_int8_t *)(dbt)->data + __off;    \
    db.h:   u_int8_t       *lk_conflicts;   /* Two dimensional conflict matrix */
    db.h:   int  (*get_lk_conflicts) __P((DB_ENV *, const u_int8_t **, int *));
    db.h:   int  (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int));
    stdint.h:#ifndef __int8_t_defined
    stdint.h:# define __int8_t_defined
    stdint.h:typedef signed char        int8_t;
    stdint.h:typedef unsigned char      uint8_t;
    xf86drmMode.h:extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
    xf86drmMode.h:          uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like just yesterday I had this same problem with Play! v1. After trying
I thought I had this figured out but it turns out I'm just deleting
Hey This is my login script, using PHP5 and MYSQLi, I just had help
So just this week I had the opportunity to re-build my development machine and
Just wondering if you had any thoughts on this problem. I want to make
I had assume I could just do this, but I don't have a way
I just got this question on an interview and had no idea how to
I just added this to my web.xml on my JBOSS server. But it had
I was just reading this article and it mentions that some organization had an
I’m having trouble getting a AJAX/JSON function to work correctly. I had this function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.